# Animation

While the animation of the Carno was done in Blender, implementing them in Unreal Engine 5 took some additional steps.

#### State Machine

UE5 uses state machines in the character's animation blueprint to determine what animation should be playing at any point of time.

As a default state, the Carno will be in its idle animation.

The condition to move from default to run (BS\_CarnoRun) is the game starting (a Boolean set to true).

Next, between running and jumping, the conditions to move back and forth is a Boolean set to True by the Spacebar key, and set back to False after the jump animation is complete.

<figure><img src="https://2691962101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F82pexs22rwhy7L3zOX%2Fuploads%2FtrLVfWTi7Z6y8k6SNIn9%2Fimage.png?alt=media&#x26;token=63a446f4-da55-4124-9209-5adcc86292cc" alt=""><figcaption><p>Anim Graph of Carno</p></figcaption></figure>

#### Blend Space

Mentioned in the previous section was BS\_CarnoRun. BS stands for Blend Space, which is what UE5 uses to blend between animations based on user-defined parameters.

In this case, I blended the Carno walking animation at regular speed and at 2x speed, controlled by a horizontal parameter "Speed".

The speed of the player movement is scaled by number of map pieces exponentially, which is explained in [Game Mechanics](https://jeremy-yeh.gitbook.io/carno-run/production/game-mechanics).

As the speed of the player movement increases, the speed of the animation increases accordingly to match the faster traversing of the level.

<figure><img src="https://2691962101-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F82pexs22rwhy7L3zOX%2Fuploads%2FeYDNXNZirMEUrxZPXOBT%2Fblendspace.gif?alt=media&#x26;token=cf8135de-42f5-4c33-bdb0-2a6348fc21c3" alt=""><figcaption><p>Animation blend space of Carno walking</p></figcaption></figure>
