- Home /
Freeze Rotation constraints doesn't work.
Hi! After i locked the rotation constraints i still can add rotation with rigidbody.AddTorque. (If i lock position constraints, then i cant use AddForce on the object.) And if the rigidbody collide with other object under the effect of addtorque , then it will ignore all rotation constraint. here the example video:
https://youtu.be/emGu-IgU7YQ (in the video i have not locked the y axis. btw no difference)
sry for my english and ty for any advice
try freezing rotation manually
void LateUpdate()
{
transform.localEulerAngles = new Vector3(0, 0, transform.localEulerAngles.z);
}
yes, it is a really easy hack, but not a good solution for me. btw i already do it in fixedUpdate, before the physics simulation.
Answer by $$anonymous$$ · May 18, 2017 at 11:05 AM
Okey i found the solution. If the rigidbody have a child collider then it recalculates the inertiaTensorRotation. I have to manually set the inertiaTensoreRotation (at my case its quaternion.identity)
Hi, I have been adding the following codes however as I perform an operation after a certain number of iterations the geometries lose the fixed position and orientation. Did you do this in update function or fixedUpdate function>
rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.transform.localPosition = Vector3.zero; rb.centerOfMass = Vector3.zero; rb.inertiaTensorRotation = Quaternion.identity;
Answer by Weetman · May 12, 2017 at 12:15 PM
From Rigidbody.constraints:
Note that position constraints are applied in World space, and rotation constraints are applied in Local space.
I could not find any reference as to which coordinate systems the Rigidbody.AddTorque uses, however in Rigidbody.AddRelativeTorque:
Adds a torque to the rigidbody relative to its coordinate system.
Therefore I presume AddTorque should add a torque in World space system, and the rotation constrains are applied in Local space. Perhaps you could try using Rigidbody.AddRelativeTorque instead.
I hope it helped!
EDIT: Actually, from AddTorque:
torque: Torque vector in world coordinates.
Thank you for your answer, but it's not relevant. Check the youtube video. it doesn't matter if the torque axis is in World or Local coordinate because the y axis should be the same.