Any tips/ideas on how to approach stair step climbing for a RigidBody based player class?

For a realistic game if you have time and skills, you can code your player IK movement to get foots able to align on stairs automatically, it's not easy if you are starting 3D. Or keep it simple, use plane on top of stairs, player capsule will be able to slide along the plane.

If the steps are small, use a capsule collider, or a sphere collider for the feet; it should bounce up the steps.

You could also have the collider be spaced so that it ends above the height of a step, and then use raycasts to move the capsule up or down when necessary. The collider would essentially be floating, so that it can still bump into things that are too high, for example. Not sure if raycasts work in C#, though (I'd assume so, but I've never used C# with Godot before).

Thanks for the input everyone!

@MagicLord that's indeed a great idea however from my past experience I believe separating player's navigation collision (capsule, cylinder etc) from player's physical collision (skeletal mesh + animations) and later syncing their behavior if required is the best way to go when it comes to troubleshooting.

@Somnivore I'm currently using RigidBody with a capsule collider for the player and 'SetLinearVelocity (some Vector3);' to get things moving. Everything works fine (even slope movement) but as soon as the collider bumps into any sort of a stairstep then player simply stops. Originally I tried to apply some force on y-axis but that comes with some "vibrating" results xD.

@SolarLune forward raycasting to check floor's height is what I'm currently thinking about too. Yes, raycasting works in C# :)

I was wondering if I could somehow force RigidBody to move based on the floor normals as long as a step's height is below a certain value (tracing forward could be useful here unless there's a better method). Not sure if that's possible at all though. Two (or more) brains are always better than one!

Attaching an image in case my description isn't good enough:

@JohnEK said: Thanks for the input everyone!

@MagicLord that's indeed a great idea however from my past experience I believe separating player's navigation collision (capsule, cylinder etc) from player's physical collision (skeletal mesh + animations) and later syncing their behavior if required is the best way to go when it comes to troubleshooting.

@Somnivore I'm currently using RigidBody with a capsule collider for the player and 'SetLinearVelocity (some Vector3);' to get things moving. Everything works fine (even slope movement) but as soon as the collider bumps into any sort of a stairstep then player simply stops. Originally I tried to apply some force on y-axis but that comes with some "vibrating" results xD.

@SolarLune forward raycasting to check floor's height is what I'm currently thinking about too. Yes, raycasting works in C# :)

I was wondering if I could somehow force RigidBody to move based on the floor normals as long as a step's height is below a certain value (tracing forward could be useful here unless there's a better method). Not sure if that's possible at all though. Two (or more) brains are always better than one!

Attaching an image in case my description isn't good enough:

Try pushing some tire against a wall that is it's half height, the tire won't be able to climb it, while the tire will climb a very small height that present less opposite force due to contact height.

For collision a capsule follows the same physics low as in reality. Most games uses Raycast for characters gameplay like jump, climb or anything, this is the way most games do.

You can do a tricks if you really don' t want to use raycast, is round your stairs, so your capsule will climb.

Physics without raycast is not good enought, i got a character capsule stuck in cube edge corner sometimes when character lands. I got the same issue outside of Godot. Many games code i seen, mixed rigibody and they used raycast to drive any direction movements, jump and landing or climbing.

Thanks @MagicLord :) I think I got it working btw. I used raytracing towards the desired direction and pushed the rigid body upwards whenever a climbable stairstep is traced. Works pretty well too!

I don't know how does it looks to have a rigibody or kinematic doing small jumps climbing stairs, if you smooth the movement it could look good. While a collision plane for stairs would do the same result finally.

Another angle to consider is whether having stairs of that nature is a good idea. When I think of any game with stairs, I think of either a slope that the avatar may or may not have a custom animation for, or a programmatical solution where normal collision with the climbable surface is not taken into account, such as with Castlevania's stairs, or when characters climb ladders. Othertimes the stairs are made large enough that it's obvious to the player that they need to jump up each step. The only situation I would think that having small steps is a necessity is for games that rely on realistic physics simulations. If the issue is that a slope allows characters to slide down them when it's intended that they stand still, or that characters bounce down slopes instead of gliding along them, there are solutions to that.

@MagicLord I'm working on a first-person prototype with emphasis on physics and although jumping-up stairs might sound a bit weird (that's what I originally thought too) it actually looks pretty good. Instead of smoothing player's movement I smoothed player's camera y-movement (only when too violent) instead. It's a trick I've used before (used in my company's last released game 'Lethe') and seems to work well.

@Somnivore good idea, especially when considering GoDot's collision layers that could allow different collisions between the player and the rest of the world ( i.e. physics). My current goal is to test how far GoDot can go when it comes to realistic physics though and the above approach could create certain issues. A good example would be a small item on the floor that supports physics let's say a book. The player should be able to step on it. Also a terrain with colliding static (or not) rocks on it. The very same stair climbing system could solve certain collision issues that could pop up in such cases. Your suggestion is still a great alternative and I'll definitely give it a go if the current approach fails.

5 years later