0 votes

So I'm trying to make a 2D platformer that plays like Super Meat Boy and I have done fairly well wen it comes to movement except for wall jumping. I tried following several tutorials but none of them really helped. So I was able to get a wall slide to work, but I'm still not able to jump off of said wall. Any kind of help is appreciated. Here is my code:

extends Actor

const TYPE = ("Beepo")
const types = ("Beepo")
const Wall_Slide_Acceleration = 10
const Max_Wall_Slide_Speed = 120
const Max_Speed = 575

var facing_right = true

var on_ground = false
var can_jump = false
var jump_was_pressed = false

onready var sprite = $AnimatedSprite

func _on_Saw_Blade_Detector_body_entered(body: PhysicsBody2D) -> void:

func _physics_process(delta: float) -> void:
if Input.is_action_pressed("move_right"):
elif Input.is_action_pressed("move_left"):
    if on_ground == true:
var is_jump_interrupted = Input.is_action_just_released("jump") and velocity.y < 0.0
var direction: = get_direction()
velocity = calculate_move_velocity(velocity, direction, speed, is_jump_interrupted)
velocity = move_and_slide(velocity, FLOOR_NORMAL)

if Input.is_action_pressed("jump"):
    if can_jump == true:
        if is_on_wall() && Input.is_action_pressed("move_right"):
            velocity.x = Max_Speed
        elif is_on_wall() && Input.is_action_pressed("move_left"):
            velocity.x = -Max_Speed

if is_on_floor():
    on_ground = true
    on_ground = false
    if velocity.y < 0:

if facing_right and velocity.x < 0:
if !facing_right and velocity.x > 0:

if is_on_wall() && (Input.is_action_pressed("move_right") || Input.is_action_pressed("move_left")):
    can_jump = true
    if velocity.y >= 0:
        velocity.y = min(velocity.y + Wall_Slide_Acceleration, Max_Wall_Slide_Speed)
        $AnimatedSprite.play("Wall Slide")
        velocity.y += gravity

if !is_on_floor() && is_on_wall():

func flip():
facing_right = !facing_right
sprite.flip_h = !sprite.flip_h

func get_direction() -> Vector2:
return Vector2(
    Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
    -1.0 if Input.is_action_just_pressed("jump") and is_on_floor() else 1.0

func calculate_move_velocity(
    linear_velocity: Vector2,
    direction: Vector2,
    speed : Vector2,
    is_jump_interrupted: bool
) -> Vector2:
var velolin: = linear_velocity
velolin.x = speed.x * direction.x
velolin.y += gravity * get_physics_process_delta_time()
if direction.y == -1.0:
    velolin.y = speed.y * direction.y
if is_jump_interrupted:
    velolin.y = 0.0
return velolin
Godot version 3.3
in Engine by (39 points)

I'd recommend to change your player movement into a state machine because it is becoming more complex and any attempt to add features will result in more bugs.
After that , it is easy to implement the wall jump by simply changing the player's state

Maybe this Game Endeavor video on wall jumping will help?

1 Answer

0 votes

Hello. This is really help you https://www.youtube.com/watch?v=rOg6oKvjCEs

by (14 points)
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.