Advanced Character Animation System for Thakuru Wars

Unreal Engine handles animation for games with a system called Animation Blueprint. It allows you to switch states, play specific animations at a time, and blend in between animations. This article will not cover basic animations, The animation we are using for the article is taken from Mixamo temporarily for this article purpose only (Not ingame)

Locomotion

Locomotion is a state of character movement with the primary being, Idle - Walk - Run - Jump. The best way to do this is to use a system called "StateMachine".

More information

https://docs.unrealengine.com/5.0/en-US/state-machines-in-unreal-engine/

(Note: The animation blueprint was created before UE5, nothing changed however some better approaches and new features have been added)

Inside the Locomotion, StateMachine Looks like this

Everything happening here is as the arrows point. Each arrow represents a state. for example: if the character starts moving -> switch to the WalkRun state. During this transition, the animation blends instead of instantly switching it.

Each can be controlled in the detail menu on how long the transition duration can be. we can even add a custom curve to the blend if we want the animation to blend more exponentially.

Even the slightest animation can have a big impact on achieving more fluid movement. for example, adding a small animation for stopping the movement makes the character act more naturally.

Strafing and BlendSpaces

Blend Spaces are an animation feature in the Unreal engine that allows blending in multiple animations based on an input value. this can be a vector input based on two values for example X axis and Y axis. These values can be input directed to the controller creating a smooth strafing action.

Multiple animations can be added to each location of the input matching the animation to the receiving input of the character.

More information on Blendspace:

https://docs.unrealengine.com/5.0/en-US/blend-spaces-in-unreal-engine/

Below is the logic behind inputs of Strafe blend space

It's further connected to Blend space handling the character movement (Notice it says female, ThakuruWars has multiple characters with different animation sets for different body types) This is switched using an Enum.

This all is happening inside the "IdleWalkRun" state inside Locomotion StateMachine mentioned above

OnSpot Rotation

Below is on Onspot rotation without foot stepping

The above Covers the strafing action but there will be cases players will stay on spot and look around or aim at an enemy. we can rotate the whole character towards the direction of the aim. but the character will still play idle animation or action animation and the legs will not move based on the direction of rotation. We first need an animation that gives the movement of turning but always the Hip forward, Which looks like this

What's happening here is the character footing as if he is rotating around. for this animation

The character takes 5 seconds to make a full 360 rotation clockwise. 360 or 0 = 5, 180 = 2.5 and so on. Now we need a way to implement it in a way to play a single frame per input value which is 0 to 360. To do this we need to convert this animation to a single-frame animation. this option is available when you right-click a play animation node.

This gives an input for time which our case is 0 to 5. Now we need a variable that inputs the axis of the character based on the direction the character is facing.

This input variable is directly connected to the frame-by-frame animation input.

Jump and Falling

Jumping is an action consisting of 3 states. reason being, when you jump, you don't know when you are gonna land. it depends on how high you jump, and how long the fall is. so it cannot be easily done using one single animation. We have to split the animation into 3 states.

JumpStart -> InAir -> JumpEnd

JumpStart - happens when the player first leaves the ground

In Air - A loop animation that plays when the Player is in the air (This is a fall animation and can be further branched out to panic fall and hard fall)

JumpEnd - Animation that plays when the character lands on the ground

Resulting

Leaning

Leaning is one of those minor changes that impact a lot and bring a more natural feeling to the character. It is not necessary from a gameplay perspective. but it's natural to lean on an angle when turning while sprinting or running. There is more than one approach to solving the lean equation but our method is "Transform Bone". It's not as natural for example using additional animation. but it does give the result we need for the game.

How "Transform Bone" work is it specify on what bone you need to transform. then it asks what kind of transform you want to apply to it and can expose the pin if you want to. We only need rotation to be exposed. and for the Pelvis bone. Then it asks if you want to Add or Replace the transform.

Add - Add the transform to the existing animation

Replace - Ignore all animation and replace the transformation completely.

This is our setting.

This will rotate the pelvis to the left or right based on your lean input.

Physics bones

Physics brings fluidity and realism to animations. and achieving this requires to setup some constraints :)

Our approach to physics is using Anim Blueprint, physics bones, and the "Anim Dynamics" node. The way how it works is it simulates bones to use physics and be only played during animation. and no external force acts on it. (unless its specified directly to the node) The reason to use this is that it's more optimized and supported by mobile devices.

The setting for Anim Dynamics

As transform bone, it asks for what bone and intensity and weight of the bone. Spring constant gives a weight for it to return to its original point like how original spring works. physics overrides animation. With applied physics bones it looks like this

Actions

Actions like Attacks, Aim shoot, are handled using montages. Montages are mostly handled inside individual character blueprints, how it is linked to animation blueprint is using slots.

How slot work is, each Anim montage has the option to use a slot and name it, for example, "FullBody". From that point, every animation you use before will be replaced with the montage when the montage is triggered. overriding any modification or state machine that comes before the slot.

Blending Locomotion and Actions

That being said. There are cases we need to combine both animations. for example when Faathuma is aiming

The method mentioned above does not give the full ability to combine both locomotion and montages.

The "Layer Blend Per Bone" node gives the ability to blend two animations together where only certain bones play a certain animation while the rest of the bones play another animation. In this case, we would want the upper body to play the montage. and Lower body to play the locomotion animation.

This node gives some options to choose what bones are affected (any sub-bone or below the hierarchy of bones will be affected by the layers). and give depth options to show how smoothly the blending should be.

The result of this looks like this.

Aiming

"Layer blend Per bone" is not a perfect solution for some cases like aiming. Since it blends through the hierarchy constraints.

it does not give fully accurate results for example during aiming, since footing and aiming both require pelvis bone movement you would want an extra step for the character to correct the aim. For that, we used "Transform Bone" on one of the spine bones. so the bone will be facing absolutely in front of the character. thus fixing the aim. This is another case of how we can use the "Transform Bone" note.



T

This result with

Some Extras

Since Thakuru wars is a class-specific game. each class contains a unique Anim set. One way is to use a state machine to separate out the states. and use an Enum to determine what character is what and use appropriate animation.

You can also use the state machine to determine some abilities. for example, Bodey's Belly Flop is an ability that uses jump, So contains 3 states as in jump. To fix that issue we used "Blend poses by Bool" to switch state when the ability is activated.


This Concludes Thakuru wars animation Blueprint



;