Spine: Skeleton.FlipX or set_hflip for spine model?


Hello! I have a Spine character where all animations are facing one direction. I was hoping to be able to flip the facing direction of the character/spinemodel with code when moving the character in the other direction (left or right). I believe I’m missing something simple but just can’t figure out what it is.

Is there a way to flip the GO or spine model horizontally without having to recreate all the animations in Spine facing the other direction? I have tried rotating the GO along the Z axis but that breaks the collision object. Scaling the GO along the X axis does not allow negative numbers. So, these methods have proved unfavorable.

Would it help me to know which Spine runtime Defold uses or are the methods listed in the Defold Spine API the only methods I’m able to use when working with Spine assets?



I think @Andreas_Jirenius might have encountered this before. :wink:



Thanks! I’m still looking through the docs.

Here [quote=“Mark_B, post:1, topic:1400”]
rotating the GO along the Z axis
[/quote] I actually meant rotating along the X axis (actually, i tried all 3).




Ok, yeah so I have encountered this and it’s a well known problem at the moment.
So, first of all: The Defold Spine runtime does not support flipX nor flipY atm. This is a problem yes and I also have been trying to work around this using the rotation of Y-axis. (for horiz flip).
This in turn as you say totally breaks the physics.
So workaround has to be done right now (like putting the collisioncomponents in a seperate gameobject and make the gameobject with the spineobject a child to it)

Reason for Spinemodel right now not supporting flip is due to how Spine translates all bones not in world space. Anyhow with Spine 3.0 I believe Nate (the dev for Spine) fixed this and changed how the bones are being scaled which means that the Defold team might have a better way of creating a solution now.

Anyhow, there is already a ticket for this (and also for weird behaviour of physics when rotated 180 degres in an axis). For now I would recommend trying out above temp solution if you want to avoid creating 2 of every animation.



Thank you Andreas! I haven’t tried your solution yet, but I have managed a solution. I have duplicated the spinemodel on my character GO. So basically, I have two of the same spine models on my GO. Within the editor, I have set the Y rotation to 180 for one of them and this works well. Changing this rotation value in the editor does not break collision objects and effectively flips the spine model as needed. I’m fairly certain this method has nothing to do with Spines bone flipping as this flips the Defold spinemodel.

What I then do in, my GO script, is turn off one or the other based on which direction the character/GO should be facing. By sticking the current spine model name in a variable (and updating that when I switch them), i use this variable for all my animation calls and only have to deal with one set of animations.

I wish I could access this editor Y rotation property through script then I could just switch the rotation of the spine model as I do in the editor. I haven’t figured out a way to do this yet.

Now, I’m not sure what kind of resource hit I incur for having two spine models in my GO, but so far it’s animating, colliding and performing quite well.


Pirate Battle

Hi. I reach necessary functionality ( flip around Y axis ) with next code

go.set_rotation(vmath.quat_rotation_y(3.141592653), "#spinemodel")

Thx to you idea about flip at 180 in editor )



@splashshadow This works but the spine model gets shifted upward when its flipped.



same problem… does anyone know how to flipX spinemodel by code?


go.set_rotation(vmath.quat_rotation_y(math.rad(180)), PATH_SPINE)
1 Like


Old topic, is there a reliable way of flipping a spine model?



Not sure. @sven?



Place spine component to personal gameobject and flipping it?
here I use this way.



Yeah, this works. Just a bit fiddly, so I wondered if there had been a fix for this.



Sadly, I think this is the only way currently. Failed trying to think of another way. :confused: