![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Krasapan |
How to check which side of the player the cursor is on (left or right)?
In my case, I need to flip the player’s sprite when the cursor is on the left/right side (size=1 - right, size=1 - left). I used for this rotation degrees of my weapon, which is facing towards the cursor:
func _process(delta):
look_at(get_global_mouse_position())
if rotation_degrees >= -90 and rotation_degrees <= 90:
find_parent("player").scale.x = 1
else:
find_parent("player").scale.x = -1
if rotation_degrees <= -270:
print("set 90")
rotation_degrees = 90
if rotation_degrees >= 270:
print("set -90")
rotation_degrees = -90
But I did not succeed: weapon and player flipped incorrectly if you shake the cursor very quickly.