Recently, our GAM111 class has been learning Unity’s built-in animation system to animate a 2D side-scrolling character.
Animations are crucial in visual media to convey movement and personality. To be animate is literally to “be alive”, and good animations will be visibly lively and convincing. A well-animated human will look starkly more human-like compared to a robotic and uncanny imposter. In games, animation allows for many creative and diegetic solutions. For example, an enemy that is close to dying might show a slow limping animation to communicate their state is, as opposed to a waning health bar above their heads. Animation is a communication medium, and similar to the human face, it can be used to convey emotion and meaning.
Unity 4’s state-machine animation system – Mecanim – compliments their current keyframe-based solution. Initially, Unity used a keyframe-based animation solution. Keyframe-based animation is similar to most animation methodologies out there. Keyframes are “junction points” in the metrics of an animated object over time, such as scale, rotation, and position, and are adjusted and interpolated between frames. Flash animations use keyframe-based approaches for their 2D animations. When animating in Flash, two keyframes need to be placed which will determine the initial and final states of the object. When the animations are played, each frame between the two keyframes will transform the object slowly from the first parameter to the last. This principle allows for basic animation for objects such as floating platforms and moving cars, where the movements aren’t complex and don’t need a highly-sophisticated solution – which is where its drawbacks present themselves. To perform detailed animations, the user would need to add separate animations, which is par for the course for non-interactive animated projects like movies. The issues underpinning this solution stems from the fact that games are interactive, and it’s impossible to move naturally from one animation to the next while in a game, until now
The new animation system that Unity has implemented is a state machine based animation system, which is designed to parallel the keyframe solution as well. Here, Unity has solved the “popping” issue with the prior system, where an animation would noticeably pop from one animation into the next, which required very dirty coding to work around. Popping animations presented a serious problem to developers, since there are so many animations that may be in progress whilst in play, and no way to seamlessly move between them. Here, the user has the ability to create a web of animations, through which the animated objects can traverse the network of animation states, and blend as they move throughout them.
Mecanim brings with it a list of interesting and useful logistical features. For example, Mecanim can provide animation layering to objects. Animation layering is useful in situations where different parts of a rig need to perform different animations or do so simultaneously, like animating a face while also animating a body. Similarly, animation-masking provides the ability for users to only animate specific parts of an object’s rig. Animation scripting is a feature which lets users execute scripts whenever the state it is attached to is reached. The example that Unity provides is triggering a laughing AudioClip when a character also makes a laughing animation. Lastly, animation weight is a feature which defines the importance which an animation has over another. Weight allows the object to ignore particular states if necessary. These features make designers less dependent in animators and programmers, and prevent time being lost to animation
As we continue to develop our 2D side-scroller, we will dive further into Unity’s Mecanim system. For our current strategy/economy-centric game, I can personally use Mecanim to inform the user of the state of their buildings. For example, I can animate a building under construction with a cartoon scaffolding rising the lowering to reveal a freshly built building. I can use different animations depending on a building’s capacity, like a brighter light source in full buildings, with bright windows, or vice versa for empty ones. I can animate the time of day, changing the direction of the sun to mimic day/night cycles. The limits are endless with Mecanim, and I’m excited to explore its features.