Player animations

The janky placeholder player animations that have been in the game for ages were long overdue for replacement with something better.  Over the past couple of months I’ve been working on sourcing better animations, setting up the animation blending and transitions, and then driving that based on game state.

I worked out that I needed animations for:-

  • Standing idle.
  • Standing jump.
  • Turn left / right in place.
  • Locomotion (forward, backward, strafe left, strafe right) at various speeds from walking to sprinting.
  • Walking and running forward jumps (for jumping while moving backwards or strafing I just use the standing jump animation, as I couldn’t find anything more suitable).
  • Seated.
  • Tool holding (right arm held out) in up, forward, and down directions, blended based on the camera view direction.

I don’t have the budget to pay for an animator, so it was quite challenging to find suitable animation content to meet these requirements.  In the end I was able to get by with a combination of a paid animation pack from the Unity asset store, some free animations from https://www.mixamo.com/, and creating some animations from scratch.

It was a fiddly process to set up the animation state machine in Unity to get all these motions blending and transitioning nicely, but I’m happy with the final outcome:-

image
image
image

First person mode

I’ve now enabled the animated player character in first person mode, the downside being that this can cause problems with bits of the body poking through the camera near clip plane, not the easiest thing to avoid especially if the camera is set to have a wide field of view.

To solve this I had to do a few tricks to offset the character and camera based on the view direction.  It also imposed restrictions on the range of motion of the upper torso and arms and therefore what animations I could use.  The end result is well worth it though:-

image
image

In first person mode the camera is now attached to the character’s animated head position, this adds a lot of life to the camera movement (e.g. “dipping” after landing from a jump), and makes a big difference to the feel of the game:-

image

Tools

Once I had the player character animations working well in both first and third person modes, I moved on to the task of adding some tool models and attaching them to the player’s hand.  Now, as the player selects between the different tools (e.g. builder, painter, etc.), the transition between them is animated, and the models are swapped.  Right now I just have simple placeholder models for the tools, and I plan on adding some transition sound effects, but here’s what it looks like so far:-

image
image