How the angle limits work in the hinge joint?

Hello everybody,

While still learning about Defold and gamedev, I’m trying to model a cannon that has the function of rotating on its stand for aiming. I have built a collection with two game objects: the cannon itself and its stand, and joined them with a hinge joint. When creating the joint, I chose some values for the reference angle(0.0) plus lower (-1.25664) and upper angle (0.314159) limit, and passed them to the function.

The problem is, the values that I considered right, don’t work as expected at all - I can’t really see my limits on the angle. Furthermore, I discovered that when I pass a non-zero reference angle (for example 0.123), the joint angle, when tracked, starts with its opposite value (-0.123).

Tracking the joint angle confirms that the limits are not respected - with the said upper angle limit (0.314159) the joint angle gets higher than that (0.867729).

I found no related mark in the documentation of Defold nor Box2D. The one clue was that the Box2D docs said:

The revolute joint angle is positive when bodyB rotates CCW about the angle point.

but I was assuming that already when calculating my limit values.

Any help in understanding the hinge joint angle limits is very appreciated :blush: