这段代码应该使用它的速度和角速度绘制一条代表物体转弯半径的直线。但是,出于某种原因,给出的半径比它应该的长得多:
AngularVel = m_Rigidbody.angularVelocity.y;
Vel = m_Rigidbody.velocity.magnitude;
//Vel = transform.InverseTransformDirection(m_Rigidbody.velocity).z; same result
float radius = Vel / (AngularVel * Mathf.Deg2Rad);
Quaternion RadiusDirQuat = Quaternion.AngleAxis(m_Rigidbody.rotation.eulerAngles.y + 90, Vector3.up);
Vector3 radiusDir = RadiusDirQuat * Vector3.forward;
Debug.DrawRay(m_Rigidbody.position + Vector3.up, radiusDir * radius, new Color(1, 0, 0.5f, 1));
我使用这篇文章作为参考:https://revisionmaths.com/advanced-level-maths-revision/mechanics/motion-circle