#Need help making a ladder in 2d platformer

1 messages · Page 1 of 1 (latest)

uneven fractal
#

I have added the ladder as part of a tilemap layer and added a raycast node to the player and made it point out the top of the player sprite. I've set up move_up and move_down in input mapping.
I've added the ladder to collision layer 8 and collision mask of 2 which the player's collision layer. As far as code, i have a climb_speed variable and @onready var ladder_ray_cast: RayCast2D = $LadderRayCast
I'm not sure where to go from here.

#

so in physics process are you detecting if the raycast is colliding

uneven fractal
#

I have if ladder_ray_cast.is_colliding():
print("ladder colliding")

#

And that confirms that it is colliding

#

okay then the player can climb

#

so if they have move up pressed move them up

uneven fractal
#

ok

#

if ladder_ray_cast.is_colliding():
direction_y = Input.get_axis("move_up", "move_down")
velocity.y = direction_y * speed

#

with var direction_y = 0

#

i was making it more complicated than it was

#

Thanks for the moral support 🙂

#

I get the player to go up and down the ladder but if i stop ascending the ladder while on it the player will slowly slide down

#

you should disable gravity if the player is on a ladder

#

Ah good point

#

Then enable it when exiting the ladder

#

yes

#

lol, i feel kind of silly now i've got it worked out

#

I just added a gravity = 0 while on the ladder and gravity = 600 in an elif