How to build a layered animated sprite

I’m building the following animated (see below). The sprite consists of a body with varying pixel art (ie. the legs are not just animated, it is different art), and a head, weapon and shield that move but the art does NOT change, only the position does. The body will never change, but the head will change quite a bit. Hair and face will pull from a random bank of 15-20 options to create variety.

The sprite currently has 3 states: Run (what you see below), Stand (no movement), Attack (different animation entirely)

What is the best way to build this in Unity? I am currently creating 3 Animations for the body (run, stand, attack), 3 for the head, 3 for the sword and shield, then I plan to change the animation used via script. I create an empty parent object and stack the Body>Stand animation, the Head>Stand animation, the Hair>Stand animation, the Sword>Stand animation, etc.

I can’t help but feel that this technique is cumbersome. I’m looking for advice and best practice for doing this. Thanks!

You can create a bone system using parents and childrens, so that you can have just 3 animations “Run”,“Stand”,“Attack” and 1 animator.
The structure would be something like

Sorry for using the code tag, but it is the only way format remains as it should be

Character (animator)
|->Body
|    |->Head
|    |         |-> Hair
|    |         |->Face
|    |->Right arm
|    |         |->Sword
|    |->Left arm
|    |          |->Shield
|    |->Legs

In each animation you would modify the position of the each transform or change the sprite of the sprite renderer if needed, as each part is a children of the Character gameObject you can easily achive this in the inspector with just 3 animations.

Thanks, that did the trick. My confusion comes from the difference between needing to swap out a single Sprite in that scenario vs. needing to swap out an Animation Clip. Since everything below the body was static and moved only via position, that solution works. If the head graphic was an animated clip, I’d probably still be a little confused. I did, however, find some code to swap out animation clips which is nice.

1 Like