Animating the Character

Posted by
December 29th, 2013 8:02 pm

I worked on Bullets are Fatal in this LD (our team’s first entry in LDs), and particularly spent a lot of time working on getting the animations to blend in with the controls and physics.

Bullets are Fatal is a fast-paced 2.5D platformer/shooter built in Unity, where our scene is 3D with 2D props and characters. I decided to give Unity’s all-new 2D functionalities a spin and, while it’s clearly moving in the right direction, it’s still very new and requires a bit of workarounds.

I’d like to share with you guys a bit of how the process went and some insights on how we developed our platformer controls and character animation. If anyone would like more details I’ll be happy to explain =)

The first part of getting the character to work was to actually make him move, for this I created an abstract class to handle Inputs, from which each type of Input derives (keyboard & mouse, gamepad, AI). On top of that, a generic Character Motor reads data from the Input class to apply physics and movement to the character. This allowed us to use the same class for the main character as well as all our enemies. The enemies process AI and feed the AI Input, which is read by the Character Motor. Likewise, the player’s inputs are fed through the hardware input readers (which process latest activity to decide which one is being used between keyboard and gamepad) and read by the another instance of the Character Motor.

This is where animation comes in. With the art assets prepared and properly imported, the next phase of work started: making the different animations reflect user input and physics. Our character was built in several separate pieces: hat, head, eyes, nose, mouth, torso, left arm, right arm and legs. Most parts have 4 variants, allowing us to mix and match to create many different combinations. We also created a shader for color replacement, so that we could make a base color somewhat like a chroma-key, and just replace that shade with whatever color we like to create more variations. Although this worked, we didn’t have time to implement a character maker, so a default light-blue clothing was the only color that our little dude ever wore.

jump_hat-01 This is an example of the “Jump” animation for the 2nd variation of our hats.

Each body part has it’s own Animation Controller, controlled by an animator script, which reads data from the Character Motor. For this the character has a Game Object for each part, with a Sprite Renderer and an Animator. Aside from all the normal variables, they had another one called ID, which was a key for a blend tree that would switch what variant of that part was the currently selected one.


This also allowed us to implement different behaviors for each part, such as a second layer for the left arm (the one that carries the gun) allowing the “Shooting” animation to be played at any moment, blending it with whatever animation was being played by other parts.

The hardest animation to get to work is the jump. At first we had anticipation, but we quickly realized that doesn’t work well because either the character starts sliding on the floor during the anticipation or you lock him in place, which is very quirky and annoying. Having removed that, the whole Jump had to be split into what we called Jump and Fall, where the first part is during the ascending part and, once the apex of the trajectory is reached, the Fall comes in. This also allowed us to easily use the same animation for cases where the character actually falls from a platform without jumping. At last we made a quick landing animation, which plays once the character is grounded. Once again, we thought of having an anticipation to landing, but that would require predicting the trajectory, which isn’t pleasant and very prone to bugs. So we cut those frames out from the animation and kept landing, with an additional rule to the legs, where the “Run” animation overrides landing in case the character is moving horizontally.

All this, unfortunately, took longer than expected, leaving no time to actually tweak values such as running speed, jump acceleration and maximum height, sensitivity and physics behavior (such as keeping momentum or not and how fast should the character “brake”).

In post-compo version we addressed this (albeit still some issues to solve), but we learned quite a lot in the process.

Here’s a quick view of the animations in action!


2 Responses to “Animating the Character”

  1. FrederickK says:

    You guys did a lot of complex things to this entry, procedural stages, random characters, shaders, animate by parts in unity…
    I’m very impressed.

  2. DamnPete says:

    Thanks! We probably tried a bit too much, since this was our first LD I suppose that was bound to happen. We ended up not having time to fine-tune the values of the controls :(

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]