Truly locking rotation on a single axis for hinges

Hi folks. I’ve been digging deep for a solution to truly lock the hinges to a single axis.
I’ve got a chained hinge rig with 3 joints. The goal is to make it work like a robotic arm, which I have set up with hinge joints, but they’re very springy.

The hierarchy is like this (in the case of using joints these are not actually parented in the hierarchy, but this is the joint connection):

  • Base (must rotate on all axes and be affected by gravity) - this is rotated by player input to rigidbody.MoveRotation()

  • Arm (can only rotate locally on the x-axis)

  • Forearm (also only rotate on local x-axis)

  • Hand (also only rotate on local x-axis)

The Arm-to-base joint is pretty solid, but the forearm-to-arm and hand-to-arm wobble on their local z-axis when the base rotates. It’s awful.

I’ve tried everything I’ve come across. Standard hinge joints don’t cut it one bit. There’s no configuration that will truly lock the YZ axes. Configurable joint isn’t really any better. Angular Y and Angular Z lock allow too much spring back to z = 0 and y = 0 even if you set their limits and a high spring value, event if you set a high spring value to the Angular YZ Drive.

I’ve also tried just directly doing MoveRotation on all of the parts, but that comes with another headache: If the above hierarchy is actually a parent-child hierarchy then using MoveRotation on a parent stops the MoveRotation on the child from occurring until the parent stops calling MoveRotation. This may ultimately be the correct choice, but I can’t get MoveRotation to work on children simultaneously.

I’ve also tried limiting the rotation in FixedUpdate by taking the current localEuler and setting the y and z to zero, but this ends up causing gimbal lock. I’ve tried researching how to lock a quaternion to rotation on a single euler axis, but all I can find is the aforementioned method which causes gimbal lock.

I’m really stuck and not at all happy with the current result with the wobbly joints. Why can’t locking YZ actually just lock YZ???

All help is appreciated, but please don’t comment with super basic suggestions as they have most likely been tried.

I appreciate the help and I know there are tons of questions like this, but their answers do not result in any success.

Thanks!

It’s the accuracy of the physics. You likely need to increase the solver iteration count when doing anything complex using joints. Otherwise they act like blancmange :slight_smile:

1 Like

Thanks for the suggestion. This is one of the many things I’ve tried. Even with the iterations up to 255 there is no difference in stability. The joints still wobble.

Hmmm, I can usually wrestle them into submission with the solver count.

Have you tried the projection settings of the Configurable Joint? They can help depending on the case.

I’m not really clear on how those work. Can’t find a good example to show me. You don’t know of one do you? I have tried adding a second joint and offsetting both on the x-axis, but their just both still springy. You’d think with a positional spring with high tension that they wouldn’t be able to move, but they sure do! It’s annoyingly crazy.

You just set whatever limits on the joint then set the projection angle to zero. Also enable angular projection mode. This ‘should’ then force the joint back into position if it misbehaves.

I’ve had mixed results with it in the past but maybe worth a try.

Unfortunately that causes a whole set of strange behavior. If I set up all configurable joints, XYZ- motion locked, YZ-Angular motion locked, projection-position & rotation with 0 distance and 0 angle, then rotation of the base causes the entire system to freak out. Even with values of 1 and 1 the whole thing spazzes as soon as the base rotates.

I may be on to something though. If I set all of their masses to 0.01, set all of their COMs to the center of the Base, turn iterations up to 7&7, turn on adaptive force, and turn on preprocessing it seems to be fairly solid when the Base rotates. However, they still rotate around their local Y if they hit another rigidbody. I may be able to solve that with a second joint. They do also still bounce quite a bit when the X drive rotates them.

The COM seems to help, but still not really a solid joint… sigh…

Well I think I’ve mostly solved it. What I ended up with was adjustments to the mass of each hinged body, no interpolations, really high solver counts (hopefully I can dial them back down, but the FPS is still good), adaptive force on, and (surprisingly) preprocessing on for all of the joints. What a trip. I wish I was able to solve this in a more general fashion that could really just lock joints, but the physics system is just too complex and surprisingly doesn’t offer a better hinge. Maybe someday!
Anyway, thanks very much for your help!

You’ll probably kick yourself, but simply tick freeze rotation on the required axis of the rigidbody.

That was the first thing I tried… Unfortunately, it’s not that simple. Axis freezing still has springiness on the frozen axis when multiple RBs are attached to each other. Also please read the original post, it does say I locked XY…