How do i flip the Sprite2D and its child's(if the sprite received a child) based on mouse position

Godot Version



i have this ‘Arm’ scene where it holds ->‘RotationPoint’>‘Pos’>‘Hand’>‘Finger’ childs
the ‘RotationPoint’ are being used to track the mouse, ‘Pos’ is just for holder for the ‘Hand’ and ‘Hand’ is the texture same as the finger
Tree structure
i tried flipping the ‘Hand’ if the cursor reached the left side of the character using this script to but it doesn’t seem to work.
using Godot;
using System;
using System.Diagnostics;

public partial class arm : Node2D {

private Node2D _child;
private Sprite2D _handSprite;
private Sprite2D _handChilds;
private bool spriteShouldFlip;

private int maxDistance = 40;

public override void _Ready() {
	_child = GetNode<Node2D>("RotationPoint");
	_handSprite = GetNode<Sprite2D>("Hand");
	_handChilds = GetChild<Sprite2D>(-1);
public override void _PhysicsProcess(double delta) {
private void Flip() { //flipping the sprite based on orientation
	var mousePos = GetGlobalMousePosition();
	var dir = Vector2.Zero.DirectionTo(mousePos);
	var dist = mousePos.Length();
	_child.Position = dir; //* (maxDistance - dist);

	//attempt flipping it
	if (mousePos.X < 90|| mousePos.X > -90) {
		spriteShouldFlip = true;
		_handSprite.FlipH = spriteShouldFlip;
	else {
		spriteShouldFlip = false;
		_handSprite.FlipH = spriteShouldFlip;


There are a few things I’d look out for.

  1. Are you getting proper access to the nodes? Since Hand is not a direct child, maybe it’s not being set as you don’t use its relative path “RotationPoint/Hand”?

  2. mousePos is relative to the world origin, I think. Eother that or the top left corner of the screen. Verify that you’re getting the expected values. You want a vector between Hand’s position and the mouse to determine if it should flip.

yea the sprites are not being recognized, that fixed that thx
idk how will grab the value from mousePos, im bad at english so idk if understand it correctly, based on my understanding, i need a node that will track the mouse distance to the Hand and give a value for me to use for flipping the hand? idk how i will get the value of that node or track it on the debuger in the godot, sorry im bad at this.