pmndrs / ecctrl

🕹️ A floating rigibody character controller
MIT License
534 stars 63 forks source link

Question: How to make a character climb a ladder? #109

Open elisherer opened 1 week ago

elisherer commented 1 week ago

I'm making a 3d game and trying to figure out how to make my character to climb a ladder using this library.

I wish to have it working "Minecraft" style, walking into the ladder should make me "walk" up. I realize I need a collider that will change some of the physics when entering it and exiting it ("while on ladder") but after playing for a while with the options, I couldn't figure it out.

Has anybody tried it? have an example? Thanks!

hichemfantar commented 1 day ago

i suppose this package could use isFlying and isClimbing states.

in the most basic implementation, you just add a sensor collider to the ladder, when the player enters the ladder sensor then you disable gravity. when the player exists the collider, you restore gravity.

take a look at this if you're willing to dig into the source code yourself https://www.youtube.com/watch?v=cIZaqeJd28Y