Unity第一人称镜头控制器

来源:互联网 发布:皮皮跑胡子 软件您 编辑:程序博客网 时间:2024/05/07 13:51
void FixedUpdate(){float h =Input.GetAxisRaw ("Horizontal");float v =Input.GetAxisRaw ("Vertical");Vector3 _xMov, _zMov;_xMov = transform.right * h;_zMov = transform.forward * v;movement = (_xMov + _zMov) * 2f;playerRigidbody.MovePosition (transform.position + movement*Time.fixedDeltaTime);float _yRot = Input.GetAxisRaw ("Mouse X");Vector3 _rotation = new Vector3 (0f, _yRot, 0f)*lookRotation;playerRigidbody.MoveRotation (playerRigidbody.rotation * Quaternion.Euler (_rotation));float _xRot = Input.GetAxisRaw ("Mouse Y")*lookRotation;currentCameraRotationX -= _xRot;currentCameraRotationX = Mathf.Clamp(currentCameraRotationX, -lookLimitRotation, lookLimitRotation);//Apply our rotation to the transform of our cameracam.transform.localEulerAngles = new Vector3(currentCameraRotationX, 0f, 0f);}


这个情况是把镜头放到人物身上,但在对镜头转动X的时候,是只转动镜头,人物本身不转动。

0 0
原创粉丝点击