• Register

Lithic is a real time strategy game with distinct RPG elements set in Flintlock Studios’ dark fantasy world, a rich Stone Age environment. Players will be able to explore the concept of cultural and technological evolution from primitives incapable of speech through to forming advanced stone tool creation. Build the origins of society in a universe where magic is abound, yet untamed and the environment is as much the enemy as other creatures are.

Post news Report RSS Under the Hood – Mecanim and its Many Uses – Part One

A look at using Unity's Macanim and what we are using it for in Lithic.

Posted by on

Hey folks, This week we'll be taking a look at Mecanim and what we've been using it for. It's a bit different to most of the blogs we release as it's a touch more technical and looks at the processes we're using than instead of the end product. On a side note we've all been super busy in the office so I must also apologise for the recent lack of blog posts, things should now be back to normal with development blogs coming again.

Mecanim is Unity's catch all solution to animation. It can be used to create animations (we'll get on to those in a minute) and to also create controllers, which handle what animation a character is playing based on parameters which can be changed via numerous methods. It's an incredibly powerful tool with scope and capabilities far beyond what I've just mentioned but I hope to explain some of its uses today.

Above you can see a very simple animation controller with parameters visible on the left and a state controller on the right. The state controller is what tells the character which animation to play based on the information in the parameter window. The lines connecting the boxes are called transitions, they link the animations together and allow me to ensure these transitions between animations look smooth. The direction a transition moves is denoted by the arrows on the line. The best way to look at transitions is to consider them as conditions, for example the Locomotion state is entered when the Parameter “AI_State_Travelling” is true (denoted on the controller by a tick box) and it will exit that state when that parameter is false. This Parameter is set elsewhere via script but the details of that are far beyond the scope of this blog! The orange box denotes the “default state” of this state machine, so the character will sit in idle when none of its conditions are met to change animation. In essence, the state machine is a flow diagram of actions and animations and can be used to quickly check the relationship between different states and parameters.

Now, we've just looked at using Mecanim to control how and when animations are played, but it can also be used to animate pretty much anything in unity. The below screenshot shows the animation window containing a pillar animation which is used on Lithic's main menu – a video of the transitions can be found here.

So there are 4 different things being “animated” here. I put animated in quotation marks as not all of what's going on here is what you'd traditionally call animation! The line denoted “Pillar1 : Position” is the only thing being animated here that I'd personally call traditional animation (I say animation too much? Animation.). The four items below it are:

PillarVFX1 – this turns on and off a sound clip as the pillar moves, in this case a grinding sound.
SmokeLit – This is a particle effect, giving the impression of dust rising as the pillar starts to move
SparksRising – another particle effect, this time it's the pretty blue sparkles that radiate from the base as pillars are made active.
Pillar 1 – This one is actually telling a script that the pillar is on or off so it can safely move on with the next bit of the menu.

As you can see - and this is why I LOVE Mecanim, it's not just for animating characters, you can use Mecanim to very quickly create particle effects and audio cues, even send variables to scripts!

This is just a very small section of what we're using Mecanim for, I'm also very aware of information overload so on the next Under the Hood we'll take a look at animation layers, State Machine behaviours and editing animation curves... sound fun? It is!

As always thank you for reading and feel free to fire away any questions you might have over@LithictheGame on the tweeters or on our very own Forum!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: