Radius too long
This piece of code is supposed to draw a long between an object and the point it's "driving" around using it's velocity and angular velocity. For some reason, though, the radius given is way longer that it's supposed to be:
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));
I'm using this article for reference: https://revisionmaths.com/advanced-level-maths-revision/mechanics/motion-circle
Comment
Best Answer
Answer by nug700 · Nov 18, 2016 at 10:33 PM
AngularVel is already in radians per second. This should be added to the docs tbh.
Your answer
Follow this Question
Related Questions
Calculate arithmetic problem from text 1 Answer
Change variable depending on other variable 2 Answers
Getting average value of slider while playing. 0 Answers
Predict the hit position 0 Answers
Check if a point is on the right or left of a vector? 2 Answers