Spines and variable sprites - Will these theories work?

I am still new to Defold, so this is more a theory discussion than a practical one at this point. I have searched the forums and have found a few discussions on the concept of making characters with variable attributes or accessories. From what I understand you can’t swap frames or sprites on the individual elements baked into the spine. What I am unclear on is if either of these 2 options would work or if this would cause performance issues.

Option 1 - Animate everything and hide
Is is possible to hide individual sprites in the spine. For example, if I animated a character with 15 different helmets, 15 swords, 15 armor, 5 different faces, etc and then at runtime hid all but the ones the user selected? How bad would this wreck performance to have unused/invisible sprites and is this even possible?

Option 2 - Parent at runtime
Could a spine be set to be mostly null graphics (or the full texture set to transparent) and then the ‘pieces’ be parented to the bones as game objects at runtime? For example, if the back to front order of the character was as follows…

left arm, left leg, body, head, right arm, right leg

If at runtime I parented the chosen graphics and accessories to those bones, would it be possible to keep the depth order correctly stacked but then use variable game objects or frames of an animation to pick the correct pieces?

Just trying to work out the best way to do this before I get too deep into animating in case this drastically changes my structure from spine or dragon bones.

Thanks.

1 Like

I think you should be able to accomplish it using Option 2.
A spine component will automatically create gameobjects for each bone in a spine model, so you can attach GOs with specific sprites to these at runtime. It certainly isn’t the ideal way to do this, but the only option I can see at the moment…

This said, we are looking into possibility to change individual spine bone attachments at runtime as well. It’s currently being designed, but I can’t say any hard date when it will be available.

4 Likes

Thanks. That gives me something to work with. With the future plans, do you know if it will use Game objects? If so I don’t mind setting up temporary code that could be adapted later to target internal elements rather than external. In theory it wouldn’t be a huge change and would give better performance once available.

I appreciate the feedback and the roadmap info.

What Sven is referring to will be part of the spine.* API and have nothing to do with game objects. You will still be able to attach game objects to the bones of a Spine model though.

1 Like