attached Hinge to two boxes and set the limit from -60 to -60 angle (yeah, like strongly -60).
In all box2d simulators no rotation of a leg, but here for some reason it has a lot of strange rotations.
In the console I outputed the current angle, there you can see that even once rotated to -60 does not make it stop.
I’m not sure what is causing this behavior.
It works at the start (i.e. stays close to 60deg), but then fails. I’m wondering if it breaks somehow, by the torque being applied after it’s thrown?
Afaik, we don’t do anything specific with the joint for Box2D.
edit:
What if you alter the reference_angle? I’m not sure about how to set that properly.
Just so happens, we’re building a physics ragdoll using hinge joints and ran into this very same problem.
The hinge respects the limits in rest, but when both bodies are rotated close to 180°, the joint angle seems to break and tries to correct itself the wrong way around. Interestingly, when angular velocity is higher this doesn’t seem to happen.
wow, thats great news because after two days of testing in different soft (like R.U.B.E) and with millions of variations in defold ive thought that the problem is on my side.
Thank you so much for your help! I tried turning off the checkbox as you suggested, and it effectively resolved the issue. It’s great to know that the problem wasn’t with my setup, and your advice pointed me in the right direction. I appreciate the time you took to look into this. Your support and the community’s input have been invaluable.
P.S. i have no idea for what cases this checkbox should be on
The setting allows the game objects to set the position onto the collision objects.
Otherwise it’s the collision objects that force the position onto the game object.
This feature was implemented before we had joints, so I think that’s the reason we missed that particular case. We need to figure out a more solid way to allo users to set the position of a gameobject and let the collision object follow.
Perhaps we could limit the ability to move collision objects to exclude objects with attached joints?
I think an overall review of the code needs to be done, with this use case in mind.
I think it should be possible to set the position of a physics object, and then let them simulate.
It might be good to print a warning for now - advising of the setting.
For the review, this is a great idea. It probably only makes sense for kinematic objects to allow setting the position, this doesn’t really make sense for dynamic objects.