What i’m trying to do:
I’m making a 2d top-down game in which the player holds a long spear. The player always looks at the mouse, and the spear always tries to match the players rotation, but can be stuck behind a wall/inside an enemy. The spear can also be used to push around objects by rotating.
How I tried to make it:
I attached the spear to the player with both a hinge joint and a relative joint.
The issue:
Everything works fine, except when the mouse crosses the negative x axis (when the players rotation jumps form -180 to 180) the spear makes a full 360 degrees turn.
What i’ve already tried:
Taking %360 of both angles didn’t fix it. I also tried adding 360 degress to the angles so one is always bigger, with no succes.
Is there any way to fix this, or do i have to write my own joint code to make things work?