How would I get my rigidbody player to walk on stairs of any height and length. I tried using an invisible ramp over my stairs but the result was pretty unrealistic and the player would fly off the ramp. Please help
[EDIT] : I solved it
or at least it works for me⦠Since I was checking if the player was grounded by comparing the current slope of the ground with the maxSlope variable and setting grounded (another variable) to true or false as necessary ⦠All I had to do then was to make sure that the current slope of the ground was greater than the maxSlope variable (Since stairs are always stacked upon each other at 90 degrees) and also that the tag of the ground was āStairsā. If so then the grounded variable would be set to true and the player then happily walks up the stairs :o)
Use a Character Controller instead.
2 Likes
As you pointed out, the correct way of doing it it using an invisible ramp (or at least, most of the games Iāve seen use this trick). It should not be a problem if you donāt have an exaggerated ramp inclination or gravity is not proportional to the playerās size (remember it should be around 2 UnityUnits.
If the problem persists, you could put the ramp into a new layer (letās say 8) and every time the player raycasts down and sees a ramp, apply some vertical force downwards to make sure he does not fly off. Itās not a very elegant solution thoughā¦
Thanks Hasho⦠I will probably go with that solution but then again if someone has something else then please do tell me.
Zethariel thats the very reason I changed to creating players with rigidbodies 
Why? A CharacterController has a variable designed SPECIFICALLY to handle stair movement ā Step Offset
3 Likes
Really? This is the first time Iāve noticed there was that variable in the CharacterController (maybe because I donāt really use it and I always create my own PlayerController). Anyway, good point.
Because it does not react realistically to physics (at least thats what I think :P)
1 Like
No, it doesnāt, true. Modern games try too hard to be realistic IMO, and (at least that is what I need) not phasing through doors is god enough for me 
2 Likes
By the way, check out the 2D platform game tutorial from lerpz. The controller uses a component to behave like if it was a rigidbody (pushing crates off when the player tries to go through them).
Thats done by a script which adds force to any rigidbody that the player collides with. So its not at all realistic (at least for me :P).
What about the locomotion system here
Actually the player is just an invisible rigidbody capsule :P⦠So I guess its not going top work 
Is your rigid body kinematic, or are you moving it by applying forces?
Nope its not kinematic. And yes I am moving it by applying forces
Iām not sure why youāre still bumping⦠you got your answer: put an invisible ramp on it. If you want ārealisticā, then if you push a big solid capsule down a set of actual stairs, it does pretty much what itās doing in game and what you donāt like: it will bounce down the stairs in a really ugly and jittery way. Thatās real life. If you want it to smoothly āwalkā down stairs, it canāt be a big solid capsule. Youād need to use an IK system like the one linked in the above post that has separate physics on the actual legs, knees, and feet rather than one big capsule.
I have managed to solve this issue with a line that solves not only any type of stairs but also keeps the character attached to the ground, do not miss out, send me an email if you are interested to know how I did it.
It only works with rigidbody + capsule collider at the moment.
ipctbunity@gmail.com