Slope Movement Is So Hard (unless you use Godot Engine)
Handling slope movement is actually too easy in Godot 4.
If you're making a platformer and want to add verticality to your levels, slopes are a great way to do that, especially if you have enemies that don't jump or if your player can ride a vehicle. But if you've tried adding slopes to your platformer, chances are you've encountered weird physics issues.
Why Slopes Are So Problematic
Slopes are notoriously hard to handle because they combine vertical and horizontal movement. Your character either hops when moving from an upward slope to flat ground or floats when moving from flat ground to a downward slope.
Due to gravity, your character typically slides down a slope when the player stops moving, so you need to snap it to the surface.
On top of that, if you have separate base classes for the player and enemies, the same issues apply to both. You'll need to update them every time you change something.
There are tons of videos about handling slopes, so many that some developers give up entirely and remove them from their games. Have you seen slopes in Hollow Knight? 👀
"I'm getting rid of every slope in my game and if you are a game developer, you should too."
— Kenneth, creator of Isadora’s Edge
But come on, so many classic platformers used slopes. My childhood trifecta: Mega Man X, Super Mario World, and Kirby Super Star all have slopes and handle them beautifully.
Please, skip to 3:55
Please, skip to 0:58
Please, skip to 0:57
They all feature slopes early in the game. I don't know if this was a technological flex or if it was so easy that they just used them everywhere.
The Godot 4 Solution
Godot Engine 4.0 fixes that, making slope handling ridiculously easy.
In the first chapter of the Platformer Essentials Cookbook, "Moving Character," we present the solution.
To handle slopes in Godot 4, just follow the Mise en Place section of the chapter:
- Add a
CharacterBody2Das the scene's root node - Rename the root node to
MovingCharacter2D - Set the Floor Snap Length long enough to reach the floor when the character is on slopes. In my case,
64.0worked. - Toggle on the Constant Speed property.

Then, toggle off the Collision/Layer that represents general environment collisions. We do this because this class should only detect other objects, not be detected by them. Remove it from the general collision layer used for floors, walls, ceilings, etc.

After that, set up basic movement by calling move_and_slide(). Attach a GDScript and:
- Add variables to control the movement forces.
- Add a variable to control the look direction on the horizontal axis.
- In the
_physics_process()callback, apply gravity to thevelocity.yaxis. For thevelocity.xaxis, multiplyspeedbydirection. - Call the
move_and_slide()method to move the character.
The basic script looks like this before adding vertical movement (like jumping):

What About Godot 3?
If you still use Godot 3, that's fair. I also prefer Godot 3. But things work differently there. There are videos showing how to achieve similar results using Godot 3.
Both techniques work regardless of slope angle, but pay attention to Floor Max Angle. Above whatever value you define in this property, Godot will treat it as a wall and prevents movement.
This approach doesn't prevent advanced movement techniques like jump buffering, double jump, coyote time, or wall slide/jump. In fact, the Wall Jumping Character recipe builds on this approach.
You don't need duplicate classes for player characters, NPCs, or enemies. It's an extension of CharacterBody2D, so every moving character can use it as a component. In fact, that’s how we implement the Bumping Enemy, another recipe in the book.
Get Started Today
Join 528 other indie game developers who bought the Platformer Essentials Cookbook. They rated it a perfect 5-star resource. Make your dream game following battle-tested recipes and share it with us!

Get the Platformer Essentials Cookbook now and create perfectly moving characters for your classic-inspired platformer games!
Get Platformer Essentials Cookbook
Platformer Essentials Cookbook
A 200+ pages ebook with 12 step-by-step tutorials with essential features to create platformer games
| Status | Released |
| Category | Book |
| Author | Ludonauta |
| Genre | Educational, Platformer |
| Tags | 2D, Asset Pack, Boss battle, Godot, Immersive, Non violent, Open Source, Tutorial |
| Languages | English |
| Accessibility | Color-blind friendly, High-contrast |
More posts
- Making a Playable Level with Godot's Platformer Essentials6 days ago
- Making a Game is Like Cooking: Your Recipe for Success7 days ago
- Weekly Update: Godot is the Ultimate tool for Platformer Games11 days ago
- Why Books Aren't Enough for Game Development Education (And What I'm Doing About...12 days ago
- Why Video Tutorials Are Holding You Back (And What to Do About It)13 days ago
- Weekly Update: New Skin, New Experience18 days ago
- Hollow Knight Inspired Boss Fight in Godot 435 days ago
- The Hidden Genius Behind Hollow Knight’s Terrain Design42 days ago
- Hollow Knight Inspired Combat with the Hazard Recipe43 days ago

Leave a comment
Log in with itch.io to leave a comment.