I’m trying to accomplish something that seems like it should be fairly simple:
I have enemy units which are displayed with a 2D sprite. All of the enemy units currently share the same animator (if the enemy unit animations become more complicated later, then perhaps it may be better to make separate animators for different categories like humanoid).
All enemy units have the same types of animations:
- Idle
- Move
- Attack
- Ability (many different abilities)
Currently the idle, move, and attack animations are all simple scale/translation animations that are shared among all enemies, but eventually each enemy may have their own idle, attack, and move animation (probably not).
I currently have it set up so that boolean parameters cause transitions between the idle, move, and attack states, which all only have one animation.
The difficulty is with the ability animations. Each monster has different abilities, and I want to be able to specify in the ability data (scriptable object) which animation each ability should use. Currently I only have a handful of different ability animations (generic spell, generic ranged attack, etc), shared among all enemies, but in the future there will be more animations specific to types of enemies (like humanoid melee attack, etc.).
What is the easiest and cleanest way to set up this type of logic in Animator?
The braindead solution seems to be:
make a separate state for every single ability animation along with a separate boolean parameter
but this seems insane and unscaleable. The logic of transitioning into and out of the ability state is the same for each ability, it’s just the actual animation that plays depends on that ability data, so it seems like there must be a better way.