3 Min. read

The Bug Squad: Minimal Mech Visuals, Locomotion and Aim

In the last post I talked about implementing a basic camera and input system for The Bug Squad. This weekend I built on top of that and set up a basic mesh and animation blueprint for the player’s mech.

Minimal mech visuals

The marketplace asset I’m using comes with a single skeleton and multiple meshes that can be combined together to customize how the mech looks.

A screenshot of the UE5 content browser showing a few assets that come with the marketplace pack I'm using

At some point I’d like to experiment with giving players the ability to customize their mechs, but for now I didn’t want to spend too much time worrying about that. Instead I’ve identified a minimal set of items needed to give the mech a more or less complete look: legs, cockpit, shoulders, arms and a weapon.

A screenshot of the mech Blueprint component hierarchy in UE5, showing a minimal set of mesh components that make up the mech

Since individual skeletal meshes share the same skeleton I’ve used master pose to synchronize animation across all components.

A screenshot of the mech Blueprint construction script in UE5, where all meshes are synced together using master pose

Let’s take a look at the animation blueprint.

Locomotion

In last week’s post I discussed the setup I have in mind for mech locomotion and aim. In particular:

  • Mechs can’t strafe.
  • Legs should face the direction in which the mech is moving.
  • Upper body (i.e. cockpit, arms, etc.) should face the direction the player is aiming at.

This is different from what happens in most twin-stick shooters where characters are usually able strafe and the whole character rotates to match the aim direction.

In Unreal I’ve used a 1D Blend Shape to blend between idle and walk animations for locomotion:

A screenshot of the 1D blendshape that interpolates between backwards and forwards movement

The SpeedRatio input is calculated as CurrentSpeed / MaxSpeed in the animation blueprint event graph. The blend space also supports a negative SpeedRatio to account for backward movement, even though I’m not really using it at the moment.

Aim

As mentioned above, I want the upper body to always face the direction the player is aiming at. This is implemented by using the absolute controller rotation to procedurally rotate the Mech_Walker_Spine_2 bone of the mech’s skeleton.

A screenshot of the animation graph in UE5

I briefly considered using Control Rig instead of the Transform Bone node since that’s also a topic I’d like to dig into, but ultimately felt overkill and decided to leave it for another time. Here’s how things look in game:

One issue with the current setup is that depending on player’s input the legs and upper body can face opposite directions, which looks odd. At some point I’ll probably revisit the setup to account for that, but what I have is more than okay for now.

(Note to self: it might be interesting to also try to reduce the max movement speed in this case, to make backward movement slightly less convenient.)

Next up: setting up the Gameplay Ability System.