How can I make my character do a wall jump?

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

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)
		$"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

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

Mrpaolosarino | 2021-07-06 06:57

Maybe this Game Endeavor video on wall jumping will help?

Ertain | 2021-07-06 09:37

:bust_in_silhouette: Reply From: ViolaRose

Hello. This is really help you