How to move up a ladder?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Maciu01

In my 3d platformer i want to add ladders, i have set up a raycast to detect collisions with ladders, but when i collide my player just stands still.

My code

	if Is_on_ladder == true and Input.is_action_pressed("move_forward"):
	gravity_vec = Vector3.ZERO
	direction += Vector3.UP * speed

so is Is_on_ladder true?

exuin | 2023-02-25 18:54

yes it is. The problem is my player wont move along y axis when i hold forward button.

Maciu01 | 2023-02-25 18:58

:bust_in_silhouette: Reply From: SnapCracklins

Where is the code in your build? Do you have it in the physics_processor… ?

If it’s in the func _input(event) that usually breaks because it’s only listening per event and not per frame.

Its in physics process, I’ve managed to make some progress, but the player now climbs the ladder way too fast.
Code:

	if Is_on_ladder == false:
	velocity = velocity.linear_interpolate(direction * speed, accel * delta)
	movement = velocity + gravity_vec
		
	move_and_slide_with_snap(movement, snap, Vector3.UP)	
		
if Is_on_ladder == true and Input.is_action_pressed("move_forward"):
	gravity_vec = Vector3.ZERO

	move_and_collide(Vector3.UP)

Maciu01 | 2023-02-25 21:43