Essentially, what I want is when the Rigidbody turns (performed by rigidbody.AddRelativeTorque) it will correct the velocity so that the velocity is relative to the transform.forward. So if I have a Global Velocity of Vector3(0.0f, 0.0f, 100.0f) with a transform.forward of Vector3(0.0f, 0.0f, 1.0f) which then changes to Vector3(1.0f, 0.0f, 0.0f) which would mean the Velocity would be updated to be Vector3(100.0f, 0.0f, 0.0f).
I've been using this to do it so far, simply using the global transform.forward * Velocity.magnitude:
This works well except if there is a negative velocity involved, for instance a Velocity of Vector3(0.0f, 0.0f, -100.0f) when transformed with this process will loose the signed value as the magnitude is absolute so instead of (using the same case as before forward = Vector3(1.0f, 0.0f, 0.0f)) the Velocity being Vector3(-100.f, 0.0f, 0.0f) it's Vector3(100.0f, 0.0f, 0.0f). There's probably a simple fix for this but I just can't see it today...
asked Nov 11 '10 at 04:32 AM
Some Programmer Type Person
You probably want to have an if, then -
answered Nov 11 '10 at 05:40 AM