unity第一人称在人物移动时转动视角,会发生轻微抽搐。
单独移动人物或单独移动视角并不会抽搐,一边动一边转头就会抽搐。
private void Start()
{
Application.targetFrameRate = 75;
rb = GetComponent<Rigidbody>();
rb.freezeRotation = true;
readyToJump = true;
}
private void Update()
{
// ground check
}
void FixedUpdate()
{
MovePlayer();
grounded = Physics.Raycast(transform.position, Vector3.down, playerHeight * 0.5f + 0.3f, whatIsGround);
MyInput();
SpeedControl();
// handle drag
if (grounded)
rb.drag = groundDrag;
else
rb.drag = 0;
}
void LateUpdate()
{
yrotate = Input.GetAxis("Mouse X") * Time.deltaTime * rotationspeed;
yrotation += yrotate;
transform.rotation = Quaternion.Euler(0, yrotation, 0);
xrotate = Input.GetAxis("Mouse Y") * Time.deltaTime * rotationspeed;
xrotation -= xrotate;
xrotation = Mathf.Clamp(xrotation, -90f, 90f);
look.transform.localRotation = Quaternion.Euler(xrotation, 0, 0);