我做了物体向着它运动的方向旋转(物体一直在运动,并没有停止),但是出现了一个问题:当物体向相反的方向运动时精灵翻了过来。我怎样才能摆脱这个?我试图修复除 z 以外的所有轴上的旋转,但没有任何好处(只是停止转动)。
旋转代码:
void Update()
{
Quaternion toRotation = Quaternion.LookRotation(Vector3.forward, rb.velocity);
transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotationSpeed);
}