Hey, I want that my CharacterController (Unity - Scripting API: CharacterController) is able to walk up stairs but doesn’t use his slopeLimit to do it, because I don’t want that the character wobbles up and down while walking. Setting the slopeLimit to 90 works, but the wobbling and shaking of the CharacterController’s pseudo capsule collider is really inappropriate for my setting.
I could built a ramp around the stair with a rotated boxcollider, but this isn’t a solution either cause the meshcollider of the stair needs to be intact for other physical objects using them.
Any idea?
My approach would be to detect the stair with clever raycasts coming out of the characterController’s “foot” and setting some values that let the character float above the stairs. Well, sounds a little messy.
A really quick/dirty/ugly solution would be to have 3 physics layers.
Player Only
Everything Else
Everything
Build the ramp on the PlayerOnly physics layer, the stairs on the EverythingElse physics layer, and the rest of your world on the Everything physics layer. Set your player to respond to PlayerOnly and Everything, and everything else in your world to respond to EverythingElse, and Everything.
It’s not a good solution, but it would work if you’re just trying to rapid prototype.
For my old FPS game that I coded, I used a raycast down instead. Whenever it collided i moved the player up gently. So it felt smooth no matter the surface area, and a small collision sphere to prevent player running into walls.