How do I climb ledges on moving platforms with move_and_slide() in 2D?

Godot Version

4.0

Question

Hey guys, a few days ago I posted this in programming, but it might not have been the right place to ask.

In my game, the player can climb walls (and ceilings.) Godot 4 makes it really easy to attach to platforms and move with them, through moving the characterbody2d with move_and_slide() and using set_up_direction() to let them attach to the side or bottom instead. Climbing up or down a not-moving ledge is also pretty easy, but since I’m not married to the way I currently do it, it isn’t relevant to my question.

The platforms are AnimatableBody2D’s ran along a Path2d with the help an AnimationPlayer, PathFollow2D and RemoteTransform.

The problems start when, on a moving platform, the player wants to climb up or down a ledge, as when you set_up_direction(), the player detaches and is therefore no longer moved by the platform.

The other issue is that, when you want to for example climb down a ledge when standing atop a horizontally moving platform, I don’t know how to get the proper positions to calculate the movement, as both the platform and character move during physics_process(). When trying to go down a forward moving platform, the character smashes its face into the floor until the platform stops or turns around.

Do you have any suggestions of what options I could look into? Thanks in advance!

1 Like

I’ve been having a similar problem where my character will fall off a moving wall, even though there is a feature for wall climbing which simply makes the character move up or down along a wall so it works great on static walls lol, but since there is no feature to keep track of the walls position so if it is moving away from the character, you will just fall down because you are no longer colliding the corresponding raycasts