Hi, I am trying to animate a player figure based on a degree value which is based on the angle_to_point function:
This is my code:
var direction = round(rad2deg(player_position.angle_to_point(mouse_position)))
print(direction)
if(direction > -165 && direction < -120):
play_animation(DOWN_RIGHT)
elif(direction > 120 && direction < 165):
play_animation(UP_RIGHT)
elif(direction > -60 && direction < -15):
play_animation(DOWN_LEFT)
elif(direction > 15 && direction < 60):
play_animation(UP_LEFT)
elif(direction < -60 && direction > -120):
play_animation(DOWN)
elif(direction > 60 && direction < 120):
play_animation(UP)
elif(direction > -15 && direction < 15):
play_animation(LEFT)
if(direction > 165 && direction < -165):
play_animation(RIGHT)
All directions work as expected except for walking right: It does not trigger. However,
if I split up the calls into two IF's it works as expected:
if(direction > 165):
play_animation(RIGHT)
if(direction < -165):
play_animation(RIGHT)
Why is that???