0
這段代碼應該用它的速度和角速度繪製一條代表物體轉彎半徑的直線。出於某種原因,雖然給出的半徑是很長的,它應該是:轉彎半徑值長
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
我想你想'AngularVel = m_Rigidbody.angularVelocity.magnitude',不是嗎? – Quantic
也許你在float float = ... line的某個地方忘了2 * pi。你得到的半徑是原來的6.28倍嗎? angularVelocity.y應該給出每秒旋轉的角速度爲(1 /(2 * pi))倍。如果它每秒有2轉,比每秒4 * pi弧度。 –
@Quantic我用它取代了它,但得到了相同的結果。 –