Cancel out the steering rotation returned from a wheel colliders .GetWorldPose(out pos, out rot);
I'm trying to get the spin rotation of a wheel from the wheelCollider, but wheelCol.GetWorldPos(out pos, out rot) returns the rotation as a world space quaternion which includes the steering information. How can I get the spin rotation minus the steering?
Quaternion worldSteeringRot = mWheelCol.transform.rotation * Quaternion.AngleAxis(euler.y, Vector3.up);
I thought I could do something like multiply "rot" by worldSteeringRot or the inverse of it, but so far I haven't had much luck in my tests.
Answer by NeilM0 · May 06, 2016 at 02:40 PM
Found a solution. Take the inverse of the wheel colliders transform rotation and multiply it by the full calculated rotation. That does the world->local translation. Then using a quaternion containing the previous frames opposite steering (-Y) rotation, multiply that by the local rotation. Now you have the proper spin of the tire without the steering included in local space.
Vector3 pos;
Quaternion rot;
mWheelCol.GetWorldPose(out pos, out rot);
Quaternion localRot = Quaternion.Inverse(mWheelCol.transform.rotation) * rot;
localRot = Quaternion.AngleAxis(-mLastYRot, transform.up) * localRot;
wheelNode.transform.localRotation = localRot;
Your answer
Follow this Question
Related Questions
How to make a 2D sprite rotate towards a specific point while facing perpendicular to the camera ? 1 Answer
Simple Quaternion.FromToRotation example please 1 Answer
How to use physics to make an object face a specific direction 0 Answers
Rotate an objects quaternion to another quaternion at a set speed 0 Answers