Rotate on one axis and check if angle is inside desired range

Hey, so i have been searching around for a long while for a solution, but i can’t seem to find any way to solve this problem.

I have a script in a 2d sidescroller that makes an arrow which is a child of my player point towards my cursor over time with slerp. This is working but has one not desired effect and that is when i rotate my player 180 degrees on x to flip him, the arrow also flips and then rotates back with lerp, i need a way to only rotate it on one axis, and leave the other completely untouched, im using sprites so rotating them on any other axises makes things look wrong.

The other problem im facing is i need a way to detect if this arrow is within 2 angles, lets say 0 and 90 (the upper right part of the game), i haven’t even found a way to get started at this, i don’t get really get quaternions and am in general having a really hard time working with rotations.

I don’t know if my explenation makes any sense but if it does and you have an answer, ill be grateful thanks.

Instead of flipping the parent game object, you can try to just flip a child game object that just hold the sprite.

you can try the vector3.Angle function with arrow.transform.forward and vector3.up



float spinangle = Mathf.Clamp(spinangle, minAngle, maxAngle);
transform.rotation = Quaternion.Euler(0,0,spinangle);

I think this should work.