Slope Limitation

Hello, I was wondering how I would go about changing slope limits, I don’t have a character controller but I was wondering if I could program it to where I can’t go up certain angled mountains.

Thanks in advance!

this is realistically already accomplished through the physics system by having a rigidBody and having it be effected by gravity.

technically you can improve this by limiting the rotational euler angles of your character other then that of gravity (so x and z) then right the character when they break the angle limits, and have gravity take over. you may even realize that just by the virtue of having a rigidbody attached to the object that they will slide down hills. this is also where you would want to flip the character back over when they go on their side, or upside down.

the way to insure this though is by manipulating the steepness of the terrain so that gravity wins.

charactercontroller.slopelimit = angle in degrees

this value is displayed publicly in your inspector in the expanded character controller view.

mark as answered