What is the best way to Move character on stairs up and down while the camera is child of the character, following behind

Looking for the best way to implement character moving up and down the slope or stairs with Havok physics engine.

I am stuck at the movement part, added a proxy geometry (a cube inclined at an angle) to be used as stair. Not sure how to use this proxy geometry and make the character appear moving up the stairs.

Please suggest what is the best way to accomplish this feature. Using the project under React Node setup.

Adding the screenshot of my project for reference.

cc @Cedric

Best way is to use shapecast.
See this blog post for introduction : Character Controller with Physics V2 | by Babylon.js | Mar, 2024 | Medium

1 Like

@Cedric Thanks for answering. Would like your opinion on few related things.

Does this demo support working on a mobile device with touch controls. Can you please direct me towards a good example that illustrates the use touch controls.

In the ergoudan demo I saw that the stairs are used with multiple Box geometries and aggregates and if a inclined box is used for a stair then the character starts sliding down the inclined aggregate. It needs a lot of aggregates and that might hamper the performance if a large number of aggregates are used.

Wondering if there’s a way to use an inclined aggregate for the stairs and make it invisible to hide it behind the actual stair mesh (Tried increasing the friction value but didn’t make any difference).

Also, I have seen one of your answers at a post where you suggested not to use a physics engine for RPG games and only use physics for collision detection.

Can you please advice on, should a physics engine be used for such games or there’s another way in BabylonJs to achieve character movement that also allows to detect a character collision with wall and obstacles and character movement on stairs?

If you can share a demo where character movement up and down stairs with collision detection is used without using a physics for the character.

Hope you are well. Quickly saw this post and remembered me of this quick PG I did:

Might be of use to you?

Else, as per using or not using a physX engine and for what purpose, this is very much depending on your scope. Of how much importance, precise collisions are essential to your project (for collisions) but I suppose moreover, whether you have other features that require physics (like i.e. shooting, object with a mass, objects that require to transform or move with an imposter, etc…). As shown in the PG, you do not necessarly need havok to move and collide a character along the map. The rest, as I said, is really depending on your scope and expectations. I hope this will help you make a decision and meanwhile, have a great day :sunglasses:

1 Like