• Editor
  • multiple skeleton setup to play a single animation library

Hi there,

We are currently working on a game that needs multiple characters playing the same base of animations. We’re usually using skins to do that, but in this case, the difference between the characters isn’t just a graphical aspect question, they all have very different morphologies (size, weight, eyes positions).

So basically, we need to apply a single animation « library » to multiple skeletons config. We though about manually merging the exported json, to include animations from a file to another. Is there a simpler way to do that ?

Thanks !

Related Discussions
...

You have multiple skeletons in Spine? Then you have multiple skeletons at runtime. Just show the appropriate skeleton at runtime. You mean you have one skeleton with animations, others that don't, and you want to use all those animations? That's a little tricky, but the data is very simple to adjust.

You want to change all the animations from the old skeleton (A) to the new one (B). Look at the source code for each type of timeline. Some have a boneIndex or slotIndex. If both skeletons have the exact same bone hierarchy and names, and the same slots and names, then those indexes will be the same because Spine sorts them consistently. The same is true for constraints and constraints indexes. After that, there are only a few timelines that still need adjustment: AttachmentTimeline has attachment names, so if you key attachments, they need to be named the same in both skeletons. DeformTimeline has a VertexAttachment, so you'll have to find the corresponding attachment (using slot + name) in B and set it on the DeformTimeline (or just never key a mesh deform). Similarly, EventTimeline has an Event, so you need to replace A's event with B's by finding it using the name (or don't key events).

There is still one more thing that you may want to adjust in the timelines. You may have transform timelines in A that key something that is different in B. Eg, say a bone in A is at y=100 in the setup pose. In B it is at y=180 (because the skeleton is much taller, or whatever). Now say A has an animation that keys that bone's Y translation at 75. Key values are relative to the setup pose, so the key value is 75 - 100 = -25. B would move from 180 to 180 + -25 = 155. That may be OK, or you may prefer to scale the values based on the setup pose difference, which is 180 / 100 = 180%. In that case you'd adjust each TranslateTimeline, multiplying the Y values by 180%. So -25 * 180% = -45 and B would move from 180 to 180 + -45 = 135. You'd do the same for X translation. Rotation, scale, and shear is probably OK as-is.

So, load the SkeletonData with animations (A), then load a SkeletonData that is just a setup pose and attachments (B). For each animation in A, process its timelines as described above and add the animation to B. Now you have a B skeleton with animations from A.

Hi Nate,

And thanks for those explanations.

I had underestimate the implication of such a move, but it could work for us. 🙂

I was thinking on how great it would be, to be able to setup multiple skeleton poses directly in the editor (in order to dispose bones to fit different morphologies). But I guess it's a very specific need !