Preventing the playing walking up a steep slope


This seemed like a simple problem at first and maybe it is but I can’t think how to do it.

The problem I have is don’t want my player to be able to walk up a surface that is above a certain steepness (this is a 3d game).

So my approach was:
Check the players height at the new desired position before moving.
Check the current height.
Compare the two and if the difference is above a threshold then the player cannot move forward in that direction.

This works great if you face the slope but if you angle yourself away from the slope you can slowly walk your way up it.

What’s the solution please?

Thanks guys :slight_smile:

Can you check the angle of the slope you are trying to walk up? If it’s above some threshold, don’t allow the player to walk up it? I’ve never done this before, but I’d imagine you can calculate the angle from the polygons of the terrain you’re heading towards.

Just my guess though.

Also, this sounds like a wonderful exploit that could lead to some interesting glitching and speed runs! :stuck_out_tongue: :smiley:

Actually i think you’ve poked me in the right direction. I could check if the new point was above the current one at all (since i don’t care about downslopes) then calculate the angle of the slope where i am by sampling 2 point perpendicular to my position then getting the angle from there.

I even already have code for this to make quadroped monsters follow the terrain without looking ridiculous.

Thanks :wink:

1 Like