Page 1 of 1

How to lock rotation of an entity without using Joints?

Posted: Mon Dec 07, 2020 2:08 pm
by UmairAndTalha
Hi there,
I am trying to implement a Rigid-body system in which I can lock any axis rotation or position whenever required. Is there any way to lock the entities rotation in X and Y and position in Z-axis only without using a joint. as it is a single entity!

Re: How to lock rotation of an entity without using Joints?

Posted: Mon Dec 07, 2020 6:51 pm
by Norbo
To lock rotation, you can set the inverse inertia tensor to all zeroes:

Code: Select all

inertia.InverseInertiaTensor = default;
You can technically lock individual rows in the tensor by setting them to zero too. Be wary, this can result in unsolvable constraints sometimes. A single body constraint that used the relevant angular degrees of freedom would be the primary cause of this. If such a constraint is added, it might spew NaNs and crash the simulation.

There is no equivalent for locking position components without constraints.

Note that you can create shapeless kinematic bodies to connect the two body constraints to. That would be the more flexible approach.

Re: How to lock rotation of an entity without using Joints?

Posted: Tue Dec 08, 2020 7:11 am
by UmairAndTalha
Thanks man
We were able to do it by setting the individual rows to zero.
we got the result we wanted.
:D