• Unity
  • Spine Game Object Draw Order Issues

Hi Esoteric Team,

I have an issue with my Spine player. He has the ability to dynamically change between weapons, IE small pistols to heavy shotguns etc. We are enabling and disabling attachments at runtime for when these weapons switches are occuring and then we are changing animations that have predetermined draw orders that should line up with the attachment changes.

The draw order for these attachments seems to be totally out of wack. For example the shotgun may appear in front of the player when it should be behind the player if he is using the pistol.

Is there something we should know about Draw Orders when enabling and disabling attachments? Is there a better way to go about populating these attachments at runtime?

Tim

Related Discussions
...

Draw order determines the order in which Slots are drawn. The currently active attachment at that slot does not matter, you can see that working in the Mix and Match example scene. I assume that you use different slots for the shotgun and pistol attachments, did you check whether they are ordered correctly in your draw-order-changing animations?

One thing to note is that keying the Draw Order completely overwrites whatever the previous Draw Order was. So if you're talking about having special animations that set up your Draw Order, but then you also have Draw Order keyed in your normal animations, the normal animations will just be overwriting whatever you had previously done.
Like Harald is saying, you could use multiple slots, lets say one is 'weaponBehindHand' and another is 'weaponInFrontOfHand', and set them to their proper draw order in Setup Mode, and then when switching weapons at runtime you can set/remove the weapon image attachments from those slots as-needed.
Not sure if any of this is your actual issue or not but figured I'd mention it 😃

Thanks for the additional hint Jamez0r, always appreciated!

Hi Guys,

So I have set the draw order custom on pretty much every animation. Each weapon type IE Heavy Weapon Left, Heavy Weapon Right, Light Weapon, Secondary Light Weapon ... has a custom draw order that places that weapon as the primary order. Basically if you are wielding the Pistol the pistol animation should determine where the draw order goes, if using a heavy weapon the heavy weapon animations should determine what the draw order is. We use a lot of animation blending but again that should be on the specific weapon. I am guessing that the animations from another weapon are being called which is causing the draw order to screw up.

tjbrunetto a écrit

I am guessing that the animations from another weapon are being called which is causing the draw order to screw up.

This sounds like a good explanation. In case you don't find the problem in your draw-order-animation calling code, we stand ready if it turns out to be a problem of the animation being incorrectly applied.

Hi Harald,

We have five layers all firing at the same time. Which layer would control the draw order of the player?

  • We have layer 0 running the movement patterns such as walking, running, falling, general animations, jumping, diving, sliding, etc.
  • We have layer 1 which handles the aiming animation by mixing between layers 1A, 1B, and 1C.
  • We have layer 1D which handles the weapon kickback firing states which are additive animations.

Would it be layer 1D controlling the draw order because that layer is technically on the highest track #.

Animation layers are applied in order from base later to the higher layers. In Unity the higher layers are at the bottom in the Animator panel, let's still call them "higher layers" to keep things easier to explain. So yes, the highest track (bottom-most in the Animator panel) will override any other layers.