Unity3d每日API积累

Rigidbody body = GetComponent<Rigidbody>();

body.freezeRotation = true;//禁止刚体旋转,FPSInput.cs


bool Input.GetAxis("Mouse Y") //鼠标往前后推,MouseLook.cs

bool Input.GetAxis("Mouse X")//鼠标往左右移动,MouseLook.cs

bool Input.GetAxis("Horizontal")//WS ↕   FPSInput.cs

bool Input.GetAxis("Vertical")     //AD ↔  FPSInput.cs

bool Input.GetKeyDown(KeyCode.X)//输入X就xxx FPSInput.cs


float _rotationX=Mathf.Clamp(_rotationX, minhead, maxhead);//限制范围【minhead,maxhead】

MouseLook.cs


 move = Vector3.ClampMagnitude(move, speed)//限制向量长度 FPSInput.cs


transform.Rotate(0, Input.GetAxis("Mouse X")*speedH, 0)//增量旋转 MouseLook.cs

transform.localEulerAngles=new Vector3( _rotationX, _rotationY,0);//设置旋转 MouseLook.cs

transform.localEulerAngles.y//获取当前的y轴旋转角度

move = transform.TransformDirection(move);//本地转全局变量


CharacterController _charController = GetComponent<CharacterController>();

_charController.Move(//Vector3 move* Time.deltaTime);//增量移动

_charController.isGrounded


猜你喜欢

转载自blog.csdn.net/animalcoder/article/details/80602625
今日推荐