How to check if rotation between PI/2 and -PI/2

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rubendw03

Hey, I’m making a topdown shooter and i wanted to make the gun that rotates around the player flip when it’s rotated to the left. I basically checked if its rotation was between PI/2 and -PI/2 but this doesn’t work. It only flips when its on the topleft of the player.

here"s my code:

func _process(delta):
	flip_v = PI/2 > pivotrotation and pivotrotation < -PI/2
:bust_in_silhouette: Reply From: kidscancode

What you’re checking there is “less than PI/2” and “less than -PI/2”, which is only going to be true for less than -PI/2. Try this:

flip_v = pivotrotation < PI/2 and pivotrotation > -PI/2

Thanks! Problem solved

rubendw03 | 2020-04-24 06:11