Unity did a nice post recently on Recore’s animation system with the layered state machine, which reminded me of something cool I have done in games before and something cool I am doing int my personal projects.
Before we get started you should read up on:
Awesome, OK here is the scenario. Say you want are making a JRPG like I am Setsuna (pictured above) and say for each ability you want the character toperforma a different character animation. Not one per character, a different character animation per ability. It would be pretty mental to set up a layer per ability they can use. Also what if you were making one of those fancy games-as-a-service and wanted to add cool abilities later on without doing a binary update. Here is one approach.
Firstly I have created this basic state machine for the characters (notice there are no transitions)
And I have created the corresponding override controller that has the default clip in the use ability slot
We are going to override this in code using the following utility function:
Now if you run the animator controller and the name of the state, and the clip you want the Use Ability state to play into this function, Unity will play the clip you loaded in!