logo-mini
Creating smooth animations for indie game Warden

Creating smooth animations for indie game Warden

Creating smooth animations for indie game Warden

26-Jun-2014 The following post is by AIE Incubator graduate Timothy Bermanseder, Co-Founder and Technical artist at Cardboard Keep.

Let’s look at Unity 3D’s Mecanim animation system and how we have implemented it in our upcoming game Warden for our playable characters. Mechanim is Unity’s animation system and allows us to create smooth transitions between animation states.


The highest level view of the characters Mecanim tree.

Every animation the character plays transitions from its “Default” state. Default is a series of nested blend trees to blend between Idle, Walk and Run animations, as well as directional movement such as sidestepping and leaning into a turn. Almost all the other states in the tree return to this point with a trigger called “Default”.
From the Default state we branch in many directions for all the different kinds of movement and actions the player can do. For example jumping, crawling and attacking

.
The Default state – Blended, not stirred.

To keep the state machine tidy we organize states into key categories such as Damage, Jumping, and Default Tasks.

The Jump state tree is quite simple. There are three animations, one for take off, one for falling and one for landing. When the player hits the jump key, we hit the “Jump trigger” to push the animation into the beginning of the jump. From here based on the “exit time” of the animation the character naturally reaches the apex of their jump and begins falling, while automatically transitioning into the fall animation. Finally, we detect if the character is grounded again and when they are the “Land trigger” is hit and the animation for landing is played.

We also have a catch all for when the player falls off ledges. This allows the character to transition into the falling state without jumping.


Jumping!

The attack tree was initially quite a simple and tame beast. After many attempts we solved the issue of having multiple weapons and styles with an integer to determine weapon type.

Each attack can combo. We count where the player is up to in their attack combo to determine which attack animation should be played. Then we check what their current weapon’s “type” is using the aforementioned integer and play the relevant animation.

For example, the player has a sword. They press attack. From default the animation transitions into attack combo 01 which is a blend tree containing all of our weapon types first combo animation. The sword is weapon type 0 and thus the combo blend tree is set to “0” and that animation is played. If the player was using a spear, their weapon type would be 1 and a different animation would have played.

We found Mecanim’s triggers to be a godsend. Initially, when we started work on Warden, triggers didn't exist yet and we had to do a lot of nonsense with bools to get it all to work.

All of the Warden playable characters share the same animations, re-targeted across multiple rigs using Mecanim’s humanoid re-target system. This is a real time saver as our animator Rob doesn't need to create unique animations for every single Warden we want in the game, allowing more time to be spent making the animations better.








Hope this was insightful, if you have any questions about using Mecanim or our game, drop us an e-mail, tweet us @cardboardkeep and don’t forget to like us https://www.facebook.com/CardboardKeep 

Peace out.
Tim