Repository: godot
Issue: Setting scale X or Y (not both) to negative value on Skeleton2D breaks Modifications like SkeletonModification2DLookAt and SkeletonModification2DTwoBoneIK
Labels: bug,topic:animation,topic:2d

### Godot version

v4.1.stable.official [970459615]

### System information

Godot v4.1.stable - Ubuntu 22.04.2 LTS 22.04 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 860M (nvidia; 535.54.03) - Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz (8 Threads)

### Issue description

**Context**

I'm working with a 2D platformer character who flips around horizontally when going left, using a full scale X = -1 on a parent containing all visual nodes, including the Skeleton2D. The Skeleton2D uses a 2-bone IK modification. I noticed that when setting scale X = -1 on the Skeleton 2D (whether the IK target is also scaled or not), the bones didn't behave as expected.

**General issue**

When a Skeleton2D (or some parent of it) is scaled on X or Y (but not both) with a negative value, modifications such as SkeletonModification2DLookAt and SkeletonModification2DTwoBoneIK do not behave as expected: bones go the opposite way of intended, as if moving away from the target.

Example with an actual character using 2-bone IK on arms:

Normal pose, arm-hand using 2-bone IK toward two targets (red crosses):
![image](https://github.com/godotengine/godot/assets/1067772/ca357db7-e7b1-4ce0-b6b7-dffd4d09beb1)

Scale X = -1, including IK targets to flip them so they stay near corresponding bones:
![image](https://github.com/godotengine/godot/assets/1067772/0547e249-68f2-4b18-a32a-d5a5d8081dd6)

Scale X = -1, excluding IK targets:
![image](https://github.com/godotengine/godot/assets/1067772/1d8fc616-a20c-42c2-8f12-4dba4c885167)

Note that three phenomena occur:
1. The bone root positions are flipped, but the bones keep their angle if auto_calculate_length_and_angle is false, using the fixed Bone Angle; or keep some relative angle else, giving the impression of changing the pose instead of doing a proper flip. It looks like the legs are broken too. But this is essentially an impression (just ignore the head and feet pointing to the right)
2. The targets may or may not be flipped (in the last picture, they are not). When not flipped, the hands should not be pointing at the right target, and cross each other's directions toward the bottom, but not go up as they are doing now.
3. The actual bug causing the hands to go up, "evading" the targets.

Another smaller example that you'll find in the MWE attached:

Normal pose (uses 2-bone IK + Look At for another bone):
![image](https://github.com/godotengine/godot/assets/1067772/f7b78c25-bd0d-4f3e-98b5-16d8d0d5cd13)

Scale X = -1:
![image](https://github.com/godotengine/godot/assets/1067772/d8f7674c-3a0b-426b-8333-6775355de038)

Scale Y = -1:
![image](https://github.com/godotengine/godot/assets/1067772/a78e86d8-c2b4-4c3c-b3ad-c2aa89dbddbd)

This time, LookAt is easy t understand, 2-bone IK much less as the bones shrink on themselves.

### Steps to reproduce

1. Open MWE which has the simple skeleton shown above setup
2. Open demo.tscn and select Skeleton2D
3. Set Scale X = -1. Observe
4. Set Scale Y = -1. Observe

### Minimal reproduction project

[Godot 4.1 - Scaling skeleton X=-1 causes 2BoneIK to avoid target.zip](https://github.com/godotengine/godot/files/12260656/Godot.4.1.-.Scaling.skeleton.X.-1.causes.2BoneIK.to.avoid.target.zip)