[SOLVED] Making first person character walk through stairs

okay so instead of sloping, is there a way to make the first person character controller code to move on the stairs? I am using the basic tutorial code that is from playcanvas and in unity engine there is step offset and slope limit and is there something similar or any way to make the characters move on the stairs?

Just put collision and rigid on the stair model, and if you don’t already have first person movement here it is. https://developer.playcanvas.com/en/tutorials/first-person-movement/

that doesn’t work, I tired that before posting

Hi @sir_akc,

Usually what games do is use a capsule shape for collider, that will have the effect of automatically climbing up steps up to a certain height.

1 Like

It seems you have definitely messed something up in your process. Can you please link your editor so I can see something?

I believe https://playcanvas.com/project/626211/overview/first-person-shooter-starter-kit has stairs

1 Like

okay so I am just going to use slope. the code @yaustar gave is good but it has some weird bugs for example, if you stand on the stairs the player will slowly slip down and will keep slipping down and when going down the stairs, the character just jumps, and no @Gabriel_Dobrzynski the code I am following isn’t messed up, its the exact same code from playcanvas tutorial and I think its just force to weight problem somehow. I will use slope for now as it does the job regardless of weight to force ratio.

1 Like

OKAY, I followed the code that yaustar gave, it has those problems I talked about(I blame physics) but it does the job but I am still going to go back to slope as it saves on Collison and rigid bodies

1 Like

solution:

You can increase the friction on the stairs to maximum 1 (or some value close to 1). That will prevent the player capsule to slilde on them.

Edit: actually that may also affect walking up on them. You will prbably have to find a good balance of friction value between stairs and players. The friction between 2 objects in Ammo is decided by multiplying their friction values. So, if Player rigidbody has friction 0.5 and stairs rigidbody friction is 0.5, then the final friction between them will be 0.25 (where 0 is no friction and 1 is max friction)

2 Likes

Another solution I’ve done on a game is to increase the friction to 1 only when standing (e.g. on a ramp) and not moving. You can do that by monitoring the linearVelocity vector.

4 Likes