Mecanim Control is an open source coding tool made to allows developers to use a wider variety of methods with Mecanim (Humanoid/Generic) animations. It allows you to not only dynamically load any animation clip during runtime, but also tap into several methods currently missing in this magnificent system.
As some of you know, currently, the Animator component and Runtime controller are still very limited due to its inaccessible code and visual dependent nature. Unfortunately Unity wasn’t able to bring us many extra options after 4.3, but they did bring us just enough to have -some- control over it. After a few weeks of Mecanim implementation over my Universal Fighting Engine toolkit I managed to somewhat create an emulated version of the old Animation component. For the most part, it works like a charm.
Features
Mecanim Control currently support the following methods:
- AddClip
- CrossFade
- GetAnimationData
- GetCurrentAnimationData
- GetCurrentClipName
- GetCurrentClipPosition
- GetMirror
- GetSpeed
- IsPlaying
- Pause
- Play
- Remove Clip
- Restore Speed
- Rewind
- SetCurrentClipPosition
- SetDefaultClip
- SetMirror
- SetSpeed
- SetWrapMode
- Stop
For more information on how to use all public methods and variables click here
What is it for?
This tool is useful for games running on Mecanim that requires more animations than the State Machine can handle. Although the visual editor is good when handling 5-10 animations, things can become a visual nightmare when you attempt to handle 20+ animations. Mecanim Control is the answer for that as it eliminates the need for the visual editor and gives the tools needed to code the animation inputs like you would in the old Legacy animation system.
How it works?
Based on a few words from Mecanim Dev explaining how to use the AnimatorOverrideController , it was just a matter of creating a system that can do animation swapping and cross fading between 4 runtime animator controllers with 3 animation states each. Since its mostly references, there are no performance issues to speak of.
Known Issues
In order to apply a crossfade Mecanim Control needs to dynamically replace the animations being played on the State Machine at runtime. Because of that it resets the current animation to its first frame of animation which may cause small graphical glitches during blending.
I’ve added an alternative approach to this issue in a zip file inside the Scripts folder called MecanimControl2.zip. Unfortunately it uses certain libraries from Unity that currently cannot be compiled into a build. Click here to read more about MC2 and Unity 5 update.
Easy to use UI
Control Mecanim like you control legacy!
As seen here:
If you can’t wait for Unity to offer a more open source animator, Mecanim Control is perfect for you.
Documentation: Mecanim Control [Universal Fighting Engine]
Any feedback is more then welcome!