Limit travel on steep angles?

I’m curious to what solutions people have made for limiting travel on steep angles ? I’m using a modified version of the better character control which doesn’t have any options to set a max angle the character can traverse.

Kinda similar here,
I use basically 3 Values to determine the actual force I will apply

float leftAngle = FastMath.acos(this.controll.getNormal().dot(localLeft)) * FastMath.RAD_TO_DEG - 90;
float forwardAngle = FastMath.acos(this.controll.getNormal().dot(localForward)) * FastMath.RAD_TO_DEG - 90;
final float totalAngle = FastMath.acos(this.controll.getNormal().dot(localUp)) * FastMath.RAD_TO_DEG;

It is probably mathematically kinda wonky, but it feels correct :slight_smile:

My biggest issue hasn’t been determining the angles it has been finding a way to push back my character once the angle is to steep. Resetting to the last good known position can cause a freeze if you made a jump prior or fell to the position.

I’m using this, it seems to work OK: BetterCharacterControl Slopes - #7 by duindain.
The code part I’m using is from vvishmaster. EDIT: Post 12 that is.

Thanks , I missed that little gem. I applied it along with my fix for the bug where you could’t jump on sloped surfaces and now we have a working BetterCharacterControl. Once I finish testing the control I’m going to submit it to be updated. The BetterCharacterControl is long overdue for an update.

I simply scale the walkdirection by this, so the steeper the slope, the slower the walkspeed in the direction of the slope

I’m curious to where you are putting this method. I have it at the beginning of the physics tick but I noticed it has a huge flaw. If you run at angle to a steep hill it won’t detect the slope properly and you can run right up the hill.

Ah ok, maybee a few more things are required :9

I have a longer than default on ground detection ray
after a certain distance the character is handled as in jumping, so if the angle is steep enough that that ray won’t connect you will glide off the slope.

The ray length must of course be fiddled around till it fits with the slopes somewhat.

So behaviour is:

no slope → normal walking
air → no changing direction, very limited air controll
small slope → starts to be slower
stronger slop → way slower
very strong slope → character cannot even stand here, as it will fall down the slope

That is similar to what I have. I have a pseudo slope detection algorithm. I find it easiest to exit the pre physics tick if my character is not on the ground. The only downside is you can’t control the motion of jumping.

A real easy way to get the angle of a slope is to get the angle of your collision capsule by measuring from the center of the X axis to the center of the Y axis. Then cast a ray down and measure the angle from the ray contact point to the center of the X axis of your capsule then get the difference of the angles multipled by 15% of the capsule height and width.

Sounds weird but it is insanely accurate and does’t require the any collision detection beyond the one ray cast which I use for to detect if i’m on the ground anyways.

The only downside is getting control of your character while falling as anytime you leave the ground the angle increases enough that detects you are on a slope.