22-09-2020, 02:57 PM
(22-09-2020, 02:12 PM)josemendez Wrote: No need to calculate the torque that would get you to a certain orientation, you could just make the rigidbody kinematic and derive angular velocity from the rotation delta. The formula for that is:
Code:// get delta rotation (difference between current rotation and previous rotation)
Quaternion delta = transform.rotation * Quaternion.Inverse(prevRotation);
// get angular velocity from that:
unityRigidbody.angularVelocity = new Vector3(delta.x,delta.y,delta.z) * 2.0f / Time.deltaTime;
Thanks! I'm trying to implement your code, do I need to put it in FixedUpdate? because the data changing the rotation is in the update loop.