Up until now I have only found examples of creating a big player character state machine with all the required animations handled by multiple state machines, states, layers etc. All fine and good, if you’re doing a simple idle, run, shoot game. However, this setup becomes unmanageable when you want to include specific animations for special cases, e.g. interacting with the environment.
I’ve seen other tutorials show, that you can be smart about states, creating “Interact_High” and “Interact_Low” states, and then trigger the needed one from the interacted object. This is ok, but not really satisfying when you want many different special animations.
How could I arrange the player’s mecanim state machine in a way, that allows environment objects to modify it? Basically, I would like to store the “Pick up object from ground” and “Pull this lever” animations within the corresponding environment objects and then dynamically assign and blend the animation of my character. Ideally, this would also work with animator override controllers, e.g. the player has default animations and gets specific environment interactions; the orc has different default animations, but still receives the same environment interactions.
The benefits I’m looking for:
- Keep the default animations on a humanoid character as simple as possible
- Extend character animations for specific interactions without adding new states to the player at edit time. Instead, create a system which allows new animations to be played by only creating a new environment object.
- Completely separate the associated data, when it is not needed anymore. If the player doesn’t have a lever to pull in a scene, I don’t want to load the lever-pulling-animation. When the player leaves a certain area, I want to dynamically unload a group of animations, which are no longer relevant.