Godot Version
Godot v4.4.1.stable
Question
I’m trying to get the player character’s sprite to change to give the illusion of rotating. I made 22 frames and had a slight idea of what I needed to do, but for some reason it stops working for the last 7 frames. I am really inexperienced with godot and coding as a whole, so I don’t know what is causing the issue.
The code:
#Runs every Frame
func _process(delta):
##Gets the mouse position
var mouseX = get_global_mouse_position().x
var mouseY = get_global_mouse_position().y
##Gives the angle from the player to the mouse
var playerDirection = (atan2(mouseY-position.y,mouseX-position.x)*100)
#Prints the angle that the mouse is to the player for debugging
print(playerDirection)
##Sets the frame to be whatever the opposite of the angle is divided by the number of frames and rounds it
frame = -round(playerDirection/22)