The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

I'm making a platform right now and I'm trying to implement a wall jump. I would like it so that when you are on the wall, you move 45 degrees up and in the opposite direction. I assume you would just set that movement and then disable the controls for a moment, but I do not know how to do that. Any ideas? Here is my platform code:

func physicsprocess(delta):

velocity.y += gravity
velocity.x = 0
wall_jump.x = 0
wall_jump.y = 0

if Input.is_action_pressed("move_left"):
    velocity.x = -speed
    sprite.flip_h = true
    ray.rotation_degrees = 90
if Input.is_action_pressed("move_right"):
    velocity.x = speed
    sprite.flip_h = false
    ray.rotation_degrees = 270
if Input.is_action_pressed("jump") && is_on_floor():
    velocity.y = jump_force
if Input.is_action_just_released("jump") && velocity.y < 0:
    velocity.y *= 0.5
if Input.is_action_just_pressed("jump") && ray.is_colliding() && sprite.flip_h == false:
    velocity.y = jump_force
    velocity.x = -jump_force
if Input.is_action_just_pressed("jump") && ray.is_colliding() && sprite.flip_h == false:
    velocity.y = jump_force
    velocity.x = jump_force
if is_on_floor() && velocity.y > 5:
    velocity.y = 5
move_and_slide(velocity, Vector2(0,-1))
in Engine by (599 points)
edited by

Have you looked at the function is_on_wall()? Maybe you could check that, and check whether the player isn't on the floor. Then you could code the player to jump off the wall.

1 Answer

0 votes
Best answer

Hi There,

I have recently tackled this issue. What I have done is create a variable like "justWallJumped" and set to false by default. Then wrapped my left and right movement in an if statement that checks if justWallJumped is true. If true then you cannot use the directional controls. Then when a wall jump is executed the variable is set to true and a timer called walljumpcool_down is started, this last for a second or two. When the timer ends a signal is produced and sets “justWallJumped” back to false allowing the player to input movement again. The time on timer will depend on how long your character spends in the air. I’ve set mine to coincide with the peak of the ark.

This implementation prevents them from being able to scale walls without another object to "grab" on to on the opposite side. They also can’t tell that all movement is disabled as the direction kicks back in at a moment when, if they were pushing away from the wall, the character would continue to do that.

by (90 points)
selected by

Thank you very much! I wasn't really expecting an answer to be honest, let alone a good one, but this helped perfectly. Thank you!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.