-2
嗨伙计们,我有一些问题,我的太空船的旋转。如果我按左箭头,并切换到右箭头旋转即时切换。我如何平滑它?unity3d太空射击运动
视频: https://sendvid.com/fek9izy3
void FixedUpdate()
{
Rigidbody rb = GetComponent<Rigidbody>();
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.velocity = movement * speed;
rb.position = new Vector3
(
Mathf.Clamp(rb.position.x, boundary.xMin, boundary.xMax),
0.0f,
Mathf.Clamp(rb.position.z, boundary.zMin, boundary.zMax)
);
rb.rotation = Quaternion.Euler(0.0f, 180, rb.velocity.x * -tilt);
}
}