• Unity
  • Issue When Flipping Sprite in Unity

In a small project I am working on, I have a character that I want to patrol around the screen a little. It chooses a random target to the left or right and heads there, waits some random amount of time, and then repeats. When the unit moves left on the screen, I am setting SkeletonAnimation.skeleton.ScaleX to -1, which is successfully flipping the sprite and animation. The problem is it seems to be flipping it on some arbitrary point some distance to the left rather than flipping it at the location of the root bone.

I've opened the project back up in Spine itself and confirmed that when I scale the root bone to -1 on the X, the flip works like you would expect.

I don't know if I am missing something simple in Spine itself, or if the problem is coming from Unity. For what its worth, the Gameobject in Unity is not parented to anything, so it's not a parent/child transform problem that I can see.

Related Discussions
...

Hello, could you share your code? This may help us identify why things are not working as intended.

Skeleton scaleX flips the skeleton over the world Y axis. It doesn't flip over the root bone, though many people leave the root bone at world 0,0 (you don't have to do that!).

To flip over the root bone, use Bone scaleX on the root bone.