<aside> <img src="/icons/list-indent_purple.svg" alt="/icons/list-indent_purple.svg" width="40px" />

Navigation

</aside>

What is this recipe

A Moving Character is the player's avatar in the game's world. It has gravity pointing downwards and snaps to the floor. It also has a smooth movement on slopes, jumps, and moves at constant speed on the horizontal axis. It's like how characters usually move in Jump 'n' Shoot games like Cuphead or Mega Man X.

Figure 1.1 - A capture of the game Cuphead.

Figure 1.1 - A capture of the game Cuphead.

This recipe is the most fundamental one for a platformer game. Players use this recipe to interact with the game world. So, this is the recipe they spend the most time interacting with.

When to use this recipe

Use a Moving Character when you want players to use an avatar to interact and explore the game world. Most platformer games use this recipe to some extent, or a variation of it. As some modern examples:

This recipe doesn't go well if you want physics-simulated movement, especially if this movement is supposed to match the real world.

If you want physically accurate movement, I recommend using a custom implementation that uses a RigidBody2D instead.

<aside> <img src="/icons/bookmark_purple.svg" alt="/icons/bookmark_purple.svg" width="40px" />

Recommended Reading

RigidBody2D

</aside>

To better understand when to apply this recipe in your games, let’s make a quick Pros and Cons comparison.

Pros

<aside> <img src="/icons/checkmark-line_purple.svg" alt="/icons/checkmark-line_purple.svg" width="40px" />

Easy to manage: it's self contained meaning minimal to no dependency.

</aside>

<aside> <img src="/icons/checkmark-line_purple.svg" alt="/icons/checkmark-line_purple.svg" width="40px" />

Full control over physics: you get what you ask from the physics engine.

</aside>

<aside> <img src="/icons/checkmark-line_purple.svg" alt="/icons/checkmark-line_purple.svg" width="40px" />

Snappy movement: the character stops as soon as player releases the keys.

</aside>

<aside> <img src="/icons/checkmark-line_purple.svg" alt="/icons/checkmark-line_purple.svg" width="40px" />

Clear animation triggers: you know where to call each animation in the code.

</aside>

Cons

<aside> <img src="/icons/close_purple.svg" alt="/icons/close_purple.svg" width="40px" />

Lacks interesting physics behaviors like friction, bounciness, and absorption.

</aside>

<aside> <img src="/icons/close_purple.svg" alt="/icons/close_purple.svg" width="40px" />

Lacks acceleration/deceleration curves to add personality to the character.

</aside>

With this in mind, let’s get into action. In the next section, we are going to setup the basics to use this feature in our Godot project, followed by a practical example of how you can integrate it.

How to make this recipe

First of all, let’s “prepare” the resources. This is a process known as Mise en Place, where we put everything in their place so we can work with them easier. Think about this part as a “pre-production” stage. Follow the steps below to get everything ready for the cooking.

Mise en Place