Character with multiple sprites

#1

Hi guys, I’m an experienced programmer (mostly OOP), new to Defold and 2D game development.
I’m trying to make a character that can change heads, various other visual details and weapons, using flipbook animations, and I’m not sure of the best approach. I’ve read some other threads, but I’m still not convinced.

Right now I have a game object for the character and managed to have it walking using multiple walking animation sprites for torso, legs, arms and weapon (sword). I’m now trying to add an attack animation, but because the new animations have different positions, I cannot reuse the existing sprites (i.e have the arm animation sprite used for walking, switch to the attack arm animation).

I can think of several approaches to solve this:

  1. Convert the game object to a collection and have the sprites that need moving attached to child GO’s, then reuse those sprites by changing position in script when changing the animation.
  2. Keeping the game object and having 1 sprite for each animation (lots and lots of sprites), that I can position in the editor, and then enable/disable as needed in script.
  3. Exporting the animations that should be interchangeable to fit a fixed size, but this sounds like a lot of work when changing the animations, adding new ones, etc.

I’m interested mostly in keeping the workflow manageable, while keeping the performance reasonable.

0 Likes

Best way to organize modular character sprite sheets (SOLVED)
#2

Definitely option #1. There’s very little cost to adding a couple of extra game objects, and no runtime cost at all (I believe) for putting them in a collection. It’ll be a bit less convenient than #2 because you can’t align the position of each animation individually in the editor, but that’s either: A) something you would have to deal with anyway, or B) Your artist’s fault for not aligning things properly. :stuck_out_tongue:

1 Like

#3

I would also look into an animation tool like Spine that provides skinning. Their skinning both offers changing of specific sprite animations and also positioning of the sprites (being converted to gameobjects). You can then also change the sprites/gameobjects in runtime by either change skin but also parent new gameobjects on bones from the spine object. Depends on how flexible you need to be.

1 Like

#4

Unfortunately I’m my own artist :smile:

1 Like

#5

I’ve chosen option 3 in the end. Tried option 1, but converting to a collection means I can barely use the editor any longer, as you can only add collections at run-time, for some reason. Keeping the GO design allows me to have properties that specify the various sprites used, and edit those properties in the editor, and also visually positioning of characters.

What’s the benefit of having an editor if you don’t use it? I must say I find some design decisions pretty strange, hopefully I’m just noob and it will all make sense at some point in the future.

0 Likes

#6

If you right-click on the base of your collection in the Outline panel, there is an “Add Collection File” option. The thing you can’t do is adding a collection as the child of a game object.

1 Like

#7

Good point. I’ve missed that.

0 Likes