unity3d移动及键鼠状态
2017-06-08 15:21
162 查看
gameObject的transform属性可以进行位置、旋转、大小的设置
位置:position,Translate(),位置的移动
旋转:rotate
大小:localScale
Vector3内置:up、down、left、right、forward、back、zero。
鼠标判断:
Input.GetMouseButtonDown(0):只要保持按下就返回true
GetMouseButtonUp(0):只要抬起就返回true
GetMouseButton(0):只要保持按下就返回true
其中,括号内参数有0,1,2
0为左键,1为右键,2为鼠标滚轮
滚轮判断:
Input.GetAxis("Mouse ScrollWheel"):接收轴的值
0为不动,大于0表示向前,小于0表示后退
鼠标滑动值:
Input.GetAxis("Mouse X")或Input.GetAxis("Mouse Y")
鼠标在平面上左右动是X,上下动是Y
往右动是正,往左动是负
键盘判断:
Input.GetKeyDown(keyCode.Space)
Input.GetKeyUp(KeyCode.LeftArrow)
Input.GetKey(KeyCode.A),只要按住一直返回true
旋转:
transform.Rotate (new Vector3(1,0,0)):绕X轴旋转
transform.Rotate (new Vector3(0,1,0)):绕Y轴旋转
transform.Rotate (new Vector3(0,0,1)):绕Z轴旋转
位置:position,Translate(),位置的移动
旋转:rotate
大小:localScale
Vector3内置:up、down、left、right、forward、back、zero。
鼠标判断:
Input.GetMouseButtonDown(0):只要保持按下就返回true
GetMouseButtonUp(0):只要抬起就返回true
GetMouseButton(0):只要保持按下就返回true
其中,括号内参数有0,1,2
0为左键,1为右键,2为鼠标滚轮
滚轮判断:
Input.GetAxis("Mouse ScrollWheel"):接收轴的值
0为不动,大于0表示向前,小于0表示后退
鼠标滑动值:
Input.GetAxis("Mouse X")或Input.GetAxis("Mouse Y")
鼠标在平面上左右动是X,上下动是Y
往右动是正,往左动是负
键盘判断:
Input.GetKeyDown(keyCode.Space)
Input.GetKeyUp(KeyCode.LeftArrow)
Input.GetKey(KeyCode.A),只要按住一直返回true
旋转:
transform.Rotate (new Vector3(1,0,0)):绕X轴旋转
transform.Rotate (new Vector3(0,1,0)):绕Y轴旋转
transform.Rotate (new Vector3(0,0,1)):绕Z轴旋转
相关文章推荐
- 【Unity3D自学记录】鼠标移动三维物体
- Unity3d 移动平台中文显示问题
- Android基础_判断WIFI移动网络状态,打开WIFI和移动网路
- Unity3D游戏制作(三)——移动平台上的角色阴影制作
- 判断网络状态 Wifi 移动网络
- Unity3D 控制物体移动、旋转、缩放
- Unity3D Player角色移动控制脚本——转载
- unity3d 网络延时状态下 ,平滑转弯
- Unity3d 框移动而物体不移动
- unity3D学习【功能实现】之十二:指定时间移动到目标位置
- Unity3D中物体的碰撞和移动所需函数与数据
- Unity教程之-unity3d移动平台性能优化专题(三):减少面数
- 汉诺塔 -- 从某个状态移动到另外一个状态
- 【Unity3D自学记录】Unity3D游戏开发之自由视角状态下的角色控制(一)
- [Phonegap+Sencha Touch][转] 移动开发32 使sencha touch的store在离线状态下也能显示数据
- Unity3d 物体沿着正七边形轨迹移动
- HTML5移动Web App相关标准状态及路线图
- 关于unity3D人物鼠标移动(初步实现)
- Unity3D让摄像机随player移动
- unity3d移动平台性能优化专题(6):动画优化