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 camera
cam.transform.localEulerAngles = new Vector3(currentCameraRotationX, 0f, 0f);
}
这个情况是把镜头放到人物身上,但在对镜头转动X的时候,是只转动镜头,人物本身不转动。