- Home /
Slope limit on player movement
I have a player with a rigidbody. I add force tto the body for moving the player. My player walks over a terrain but is able to walk up mountains that are to steep to climb. I want to limit the player so it cannot walk up a slope that is to steep.
I know there is a CharacterController component that has this functionality, but I have to use the rigidbody, so I want the same but on my rigidbody.
I can get the normal of the triangle I am standing on, and calculate its angle, but I cannot seem to make the player stop moving up the slope. Only make the player stop moving (which makes the player unmovable once it hits a angled slope)
Any ideas how to solve this problem?
Answer by DoctorWhy · Oct 11, 2012 at 09:50 PM
I learned the hard way that walking in a 3D environment can take some serious programming. There are a lot of instances you have to think about. I would recommend yoinking what is on the CharacterController and blending it in with yours, if you insist on using your own.
But a simple answer, by the sounds of it, try and do a check on where the player wants to move, not the current place the player is standing.
EDIT: Thinking about it, that may not work exactly, because if they are walking down the slope, they will get stuck... Ya... just look through the CharacterController and figure out how it does it. If you plan on adding jumping, you are going to have a hell of a time if you want to use your own script.
How do you check out the code of the CharacterController? I already tried to find it. Jumping wont be allowed :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613082207im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Slope Limitation for Rigidbody Conundrum 3 Answers
climbing the hill? 1 Answer
How to detect ground slope angles in 3d? 1 Answer
Limit distance from center 0 Answers
Preserve horizontal speed on slopes 1 Answer