Godot Version
Godot_v4.2.2-stable_mono_win64
Question
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
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) {
Flip();
}
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);
LookAt(mousePos);
//attempt flipping it
if (mousePos.X < 90|| mousePos.X > -90) {
spriteShouldFlip = true;
_handSprite.FlipH = spriteShouldFlip;
}
else {
spriteShouldFlip = false;
_handSprite.FlipH = spriteShouldFlip;
}
}
}
`