u3d脚本入门二,键盘控制物体上下左右和缩放(原创)
2016-04-24 22:42
176 查看
#pragma strict var np:GameObject; function Start () { // 动态创建也可以 //np = GameObject.CreatePrimitive(PrimitiveType.Cube); } function Update () { if(Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D)){ np.transform.localRotation = Quaternion.identity; print('dddddddd'); } if(Input.GetKey(KeyCode.A)){ np.transform.Rotate(0,0,-5); //np.transform.Instantiate(np,Vector3(0.3,1,0.5),Quaternion.identity); } if(Input.GetKey(KeyCode.D)){ np.transform.Rotate(0,0,5); } if(Input.GetKey(KeyCode.W)){ np.transform.Rotate(-5,0,0); } if(Input.GetKey(KeyCode.S)){ np.transform.Rotate(5,0,0); } if(Input.GetKey(KeyCode.Q)){ np.transform.localScale += new Vector3(0.1F, 0.1F, 0.1F); } if(Input.GetKey(KeyCode.E)){ np.transform.localScale -= new Vector3(0.1F, 0.1F, 0.1F); } }
转载于:https://my.oschina.net/uvvv/blog/665482
相关文章推荐
- Unity用键盘控制物体左右旋转前后移动的c#脚本
- unity四元数控制物体的旋转,与Rotate的比较,wasd键控制场景前后左右,按下鼠标中键控制场景上下,滑动滚轮控制场景上下,缩放,鼠标左键控制相机视野的上下左右
- Unity 3D 控制物体上下左右均匀移动脚本
- U3D 点击按钮控制物体上下左右移动,并变化按钮文本
- JS实现用键盘控制DIV上下左右+放大缩小与变色
- js实现上下左右键盘控制div移动
- 键盘控制div上下左右移动 (转)
- unity中键盘WASD控制。(WS控制物体前后移动,AD控制左右旋转。)
- css3 来实现图片在指定容器内等比例缩放,并控制中上下左右居中
- js实现键盘的上下左右控制图片移动
- U3D实现键盘控制物体方向
- 【Unity 3D学习】获取鼠标滑动方向(上下左右)-控制摄像机围绕物体旋转
- 键盘控制div上下左右移动
- JS键盘事件及键盘控制上下左右移动
- Unity 3D 控制物体前后左右均匀移动脚本
- unity3d 鼠标控制物体上下、左右、旋转
- js实现按键球,小球随键盘上下左右控制移动
- js实现用键盘控制DIV上下左右+放大缩小与变色
- python 键盘上下左右控制
- Unity 3D 控制物体前后左右均匀移动脚本