my player's arm won't rotate towards the cursor

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

im trying to make my player’s arm rotate towards my cursor but it rotates very slightly and in the wrong direction here’s my code:

func arm_follow():
var mouse_player_dif = get_global_mouse_position() - $"detective spritesheet/arm_joint".position  
$player_arm.rotation_degrees = rad2deg(atan2(mouse_player_dif.y,mouse_player_dif.x))
:bust_in_silhouette: Reply From: dustin

in the atan2() function, the first input shoud be the x value, and the second one the y value. in your code, you put y first then x.

also, you shouldnt have to use the rad2deg() func because you can just set the rotation in radians to the rotation property of the arm (since it reads rotation in radians already)