Hello, I'm working on a simple game, and still learning this engine. I have a problem with mouse movement, the best I can describe is like this, when I move the mouse from one side to the other, it mirrors the actual sprite and also the mouse movement how could I fix this?
Here is me moving the mouse from top right to top left, as you can see the sprite mirrors diagonally and the mouse movement is flipped.
here is the actual movement code:
func process(delta):
update_arms_position()
func update_arms_position():
if arms_sprite == null:
print("Error: arms_sprite is null!")
return
# Get the mouse position
var mouse_position = get_global_mouse_position()
# Check if the mouse is to the left of the player
var is_mouse_left = mouse_position.x < global_position.x
# Mirror the mouse position if it's on the left side of the player
if is_mouse_left:
mouse_position.x = global_position.x - (mouse_position.x - global_position.x)
# Make the arms look at the mouse position
arms.look_at(mouse_position)
# Get the current rotation angle
var angle = arms.rotation_degrees
# Limit the rotation angle
if angle < -20:
angle = -20
elif angle > 20:
angle = 20
# Set the new angle
arms.rotation_degrees = angle
# Move the animated sprite to the arms' position
arms_sprite.position = arms.position
# Mirroring the arms is not used here
arms_sprite.flip_h = is_mouse_left # Flip the arms based on the mouse position
Best regards.