angular limits

I want to restrict the rotation around the x axis of my configurable joint, but my limits don’t work. That’s why I tryed to do all on the y axis.

joint.angularYLimit = new SoftJointLimit() { limit = 20.0f };
joint.angularYZDrive = new JointDrive{ maximumForce = 10.0f, positionSpring = 0.0f, positionDamper = 0.0f };
joint.angularYMotion = ConfigurableJointMotion.Limited;

this works… but when I try to do the same on the x axis… nothing works… those limits are ignored and I don’t know why.

joint.lowAngularXLimit = new SoftJointLimit() { limit = 20.0f }; // also -20.0f doesn’t work
joint.highAngularXLimit = new SoftJointLimit() { limit = 20.0f };
joint.angularXDrive = new JointDrive{ maximumForce = 10.0f, positionSpring = 0.0f, positionDamper = 0.0f };
joint.angularXMotion = ConfigurableJointMotion.Limited;

… so, what’s wrong? … or what am I missing?

Now that’s great… typical rubber duck debugging… here’s the answer:
those joints seem to be pre-configured (in my case at least) and they had the values of 160 low and 160 high… what I did now was, I did set the high first to 90 and then the low wo -20 … but unity did ignore the high value, because it was lower than the low value (160) that was already in… I changed the order and I’m not first setting the low value and later the high value (of course I’m checking the old values now first, just to make sure I’m not running into this problem again… or just set it 2 times). … but, now it works… I didn’t expect, that a simple assignement operator doesn’t work and I never checked that… maybe this helps someone in the future when he/she is finding this

Old topic, but I was also having issues with this. I was creating a new configurable joint at runtime and assigning values. I could seemingly get everything other than low angular X and high angular X to work.

I was setting min to -177 then max to 0.

Changing the order in which I set them fixes the issue;

setting max to 0 then min to -177.

(side note, you have to specify your min value as a negative otherwise it will just clamp to 0)