+4 votes

So I'm using the 2.2 alpha version of Godot and fiddling with moveandslide for a kinematic character, but I'm having issues with movement along slopes.

I notice the demo just uses a constant FLOORNORMAL Vector2(0,-1). I figured maybe I could do a getcollisionnormal() to replace the FLOORNORMAL, but that didn't seem to work out too well. I set up a state machine to print out the current state and sure enough, it's constantly switching between "ground" and "air" so long as I'm moving on the slope.

Is there an easy way to fix this so I stay on the "ground" when going uphill/downhill? Gravity is already set decently high (around 3000), which comes with its own issues so I'd rather not make that any higher.

Preferably, I'd like to avoid using a bunch of raycasts to detect collision sideways and beneath in order to set specific x and y velocities.

in Engine by (23 points)

I'm still struggling with slopes with and without moveandslide with a fixed speed...

Going down in steep slopes is my bigger problem, maybe limiting the x speed when the normal is at an angle > PI or when the remaining Y motion is too big.

But a raycast may be unavoidable to get floor normal when going down (mostly to slow X and prevent the starting jump that ruins all the movement).

In the github demo project, there is a platformer demo that uses moveandslide and almost solves slope issues, i think because the controller does something like an accelerated movement.

Remember that moveandslide is still a work in progress, I don't know if it will suffer some changes or even if will be added to Godot 3.

I have a similar problem, not using moveandslide (but using both move and slide).
My solution attempt was to do an extra 'move' downwards after my horizontal motion, then if that move hits floor, keep it, otherwise undo it and go into "not on the floor" mode.

However, this solution causes a different problem - it turns out that move(0, 3) hitting a diagonal slope causes a small amount of horizontal motion, which causes ugly disruption when walking uphill, and causes unwanted sliding downhill.

I think that's a bug (move shouldn't cause any motion you didn't ask for!) so I've filed a bug. https://github.com/godotengine/godot/issues/8603

Apart from that issue this seems like a pretty good solution, significantly simpler than a mess of raycasts.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.