Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

[GODOT] Deal with slopes in a platformer

A topic by Disktra created Feb 16, 2018 Views: 947 Replies: 2
Viewing posts 1 to 2

Hello there !

I'm began using the version 3 of Godot since 2 weeks or so and I'm facing a problem with slopes tiles. Let me explain a little bit.

My character can move and jump normally and the collision are working well. But I'm trying to make it walk up or down the slopes and I don't know how to make it work. My tiles have a CollisionPolygon2D and my character a CollisionShape2D (Rectangle).

And as you can see below, the collisions seems not to be working properly and my character is "projected" when it reaches the top of a slope:

I've switched to Godot because I was working on GM:S 2 and handling Tile Collisions was terrible. Maybe I don't really know how to use this engine properly, but I always have this problem. I've looked at many articles and videos but no solutions were convincing me. This article was very good but I can hardly understand how does it works. For the moment I want only 45° slopes (but maybe for futures projects there will be other angles).

If you have some tips on clarifications about this topic it could help me a lot. Thank you very much and have a nice day ! :)


Godot has a Kinematic 2D Platformer demo that does what you are looking for.

Video demo

Collision is one of the most challenging parts in programming basic gameplay because of the mixture of geometry problems(what collides) and timing/synchronization problems(when/what order things resolve, breaking a continuous movement along multiple axes into simpler one axis steps, resolving unexpected overlaps from objects spawning or teleporting). As needs get more and more complex all games eventually need to create custom solutions instead of relying on a generic engine collision system.

Fortunately for basic behaviors like tile worlds with slopes we do have a lot of examples to work off of now!


Thank you very much for your help triplefox :)

It's so obvious I didn't thought to give a look at the examples first. I've found how to deal properly with slopes at least ^^ There's a little problem left though: Maybe it's because Godot uses the Physics engine to manage collisions and movements but when my player moves up along a slope, he jumps a little bit after reaching the top of it. I guess it's because of the momentum of something like that. It's not very a nuisance for the moment but I'll probably need to find another way to correct this...

I still need to learn the engine, but again thank you for your help ;)