If your node structure is:
Player
>Sprite
>Collision2D
>Position2D
>>Sprite
Changing the x scale of Player should cause all of the children to flip their horizontal positions. Again this is pretty hacky any may have unintended consequences. This is the more proper way:
if global_position.x - get_global_mouse_position().x < 0:
flip_children_right()
else:
flip_children_left()
func flip_children_right():
$Sprite.position = Vector2(16,16)
# (probably)
$Sprite.flip_h = true
$Position2D.position = Vector2(16,16)
$Position2D/Sprite.position = Vector2(16,16)
# (probably)
$Position2D/Sprite.flip_h = true
func flip_children_right():
$Sprite.position = Vector2(-16,16)
# (probably)
$Sprite.flip_h = false
$Position2D.position = Vector2(-16,16)
$Position2D/Sprite.position = Vector2(-16,16)
# (probably)
$Position2D/Sprite.flip_h = false
Instead of Vector2(16,16)
and Vector2(-16,16)
you should go through the editor to see what positions look good for your nodes in a left facing direction, and a right facing direction. You should already have one of those directions so half the job is done. If you make the x values negative they should probably give you something close to facing the other way.
If your sprites are facing opposite the mouse chance the < 0
to > 0
or vise versa.