![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | shoyguer |
So I’m trying to make the character change the sprite according to where the mouse is, so the character can “rotate” and be more realistic.
But somehow it’s not working then the rot variable is positive. When it’s negative it works properly.
Is it a bug in the engine or something?
And how am I supposed to fix it?
Thanks!
Here is the code:
func bow(rot):
$Bow.look_at(get_global_mouse_position())
if Input.is_action_pressed("mouse_left"):
$Bow.play("Charge")
else:
$Bow.play("Idle")
#Facing Directions
#Right
if (rot >= -45) or (rot <= -315) or (rot == 0) or (rot >= 315) or (rot <= 45 and rot >= 0):
facing_direction = Vector2(1, 0)
#Left
elif (rot >= 135 and rot <= 225) or (rot >= -225 and rot <= -135):
facing_direction = Vector2(-1, 0)
print("it's working")
#Down
elif (rot < 315 and rot > 225) or (rot > -315 and rot < -225):
facing_direction = Vector2(0, 1)
#Up
elif (rot < 135 and rot > 45) or (rot > -135 and rot < -45):
facing_direction = Vector2(0, -1)
animation()
print(rot)