Wednesday, 14 May 2014

Mecanim!! Animations!

Flow charts... exciting, huh? Well it's about as visual as programming gets. Unity has a built in animation tool called Mecanim that handles all your animation transitions for you. (you have to set it up your self ofcourse). You create your animation states, then link them up according to your needs. This creates transitions between you animations. You can then adjust the blend settings for each transition. You set up parameters that control when a transition will take place, each transition has a condition that will initialise the transition.

 This first screenshot is of the main character's animation state machine. As you can see, most of the states lead back to the state "Idle". This is becuase "Idle" is the default state and other states will transition from this. "Any State" is what it says it is. You can set up transitions to a state and not have to specify what state it is transitioning from. This is mainly used for animations that do not need to blend with any other specific animations, such as a jump or attack.


This second screenshot is from the enemy monkey's animation state machine. It follows a similar structure to the main player's state machine, apart from most states transition from "Any State". The reason for this is because of how the enemies movement works.

After the state machines are set up, you then simply have to code in when you want transitions to take place by setting the parameters values in your scripts.

No comments:

Post a Comment