• Editor
  • Multiple skeletons & image draw order

I have two skeletons. Let's say skeleton A needs to give a hug skeleton B - one arm needs to be behind skeleton B's entire draw order and the other arm needs to be on top of that draw order. This is just an example, my actual situation is more like needing skeleton A to be in front of one piece of scenery on skeleton B but behind another piece of scenery also on skeleton B.

Even if it cannot be done in the editor, could this achieved at run time?
Should I just be making a separate skeleton for foreground objects? *

(* In a more complex environment this wouldn't be an option. But I have no pressing animations on skeleton B that can't be broken up into two separate skeletons. I just wanted all of skeleton B to share the same root bone so all my images on it could be moved at once. No big deal. It just kind of sucks I want skeleton A in the middle of the draw order for all that's going on in skeleton B.)

I just wanted some thoughts. For now, I'll try my own solution of making another skeleton for the scene.

Related Discussions
...
  • Modificato

There's currently no solution to this in any runtimes save for writting your own renderer (which depending on your runtime might actually not be that hard. If you are using a renderer that's essentially 3D (cocos2dx, unity, unreal, etc.) and only look at your models from the front with an orthographic projection, you might be able to achieve what you want by offsetting the rendering of attachments on the z-axis, then positioning your two overlapping models on the z-axis so their draworders work (kinda). Since the offset is constant it might be tough to achieve the exact ordering you want. Here's an example for the z-offset in Unreal Engine 4 Spine-UE4 Runtime Documentation: Depth Offset

To add to that, and for anyone wondering on the Unity side.

What @badlogic described with Spine renderers in 3D engines is true when your rendering/shader code writes to the depth buffer.
This is not true for the default shader that Spine-Unity uses– Spine/Skeleton, keeping with how Unity's 2D system and sprite shaders work.

The solution there was to let the user define slots in the Draw Order list as points where the render is separated, so the skeleton can be rendered in two or more renders/batches. Then you can sandwich renders between them by specifying their UnityEngine.Renderer sorting order values. If you did this with two separate skeletons, they can hug with predictable results.

Fortunately, this solution comes with the package. https://github.com/pharan/spine-unity-docs/blob/master/SkeletonRenderSeparator.md

For other runtimes, a similar idea would be to have a renderer that only renders a specific subset of the slots at a time (eg, render slot 0 to 5, then something else, then slot 6 to 10), instead of all the slots in the skeleton.