I have a sprite in Unity 2019.3. It is animated like so (with provided mockups):
- Its base animation is just one frame; i.e. it has the same
Sprite
whether idle or moving. - When the player is invincible, the ship flashes in and out. This is implemented by setting the alpha to 0 and 1 and back.
- The player can acquire up to three levels of shields. The is implemented as a child
GameObject
with its ownSprite
(but not its ownAnimator
). - When a player acquires a power-up, they briefly flash colors. This can happen while they're shielded, invincible, or both. This is implemented with a custom palette-swap shader, not by replacing the
Sprite
.
These animations are all independent of one another, and can all occur at any time. For example, when a shielded player takes a hit their shield downgrades but they also gain brief invincibility. It would look like this:
A single state machine to account for these possibilities (and others, depending on whether or not I add other power-ups or mechanics) would be prohibitively complex. So I'm going with animation layers.
I was hoping that it would be as simple as adding separate animation layers with their own state machines, then marking each layer as additive. Nope. I have no idea what I'm doing.
How can I use Mecanim to animate my sprite as I have previously described?