Walljump problems with pushing off the wall

Godot Version 4.3


Hey guys!
Im new to godot and programming. I managed to setup a player controller in 2D. I wanted to make a walljump but I got a few problems with that. I was able to get the player jumping off the wall.
But when the player makes the jump it changes the x-velocity just till the Player reaches the max jumpheight. When falling velocity.x is 0. So the player just stopps mid air.

simplified, the code for the jump process looks like this:

if Input.is_action_just_pressed("jump"):
     velocity.y = JUMP_FORCE
     velocity.x = 1000

(JUMP_FORCE is -600 and the gravity is 200)


please help me!

Use the built in Godot Forum script parser, and copy paste your entire script in it.
It looks like:

extends Node3D

Basically add ``` at the start and end of ur code.

1 Like

Are you using the 2D basic platformer template? Can you show more of your code; I’m betting there is another section of your code overwriting velocity.x again, like the if direction: block in the basic template.

`I deleted the wall jump. First I want to get a the basics done. I want that if a special key is pressed that the player moves towards left or right while also moving upward. And not stopping moving x until it is on ground again.

here is my code is have for the controller (please help me):

``
func movement(direction):
var was_on_floor = is_on_floor()

velocity.x = move_toward(velocity.x, MOVE_SPEED * direction, ACCELERATION)

if is_on_floor() or coyote_jump:
	is_jumping = false
	can_double_jump = true
	if Input.is_action_just_pressed("Jump") or buffered_jump:
		velocity.y = JUMP_FORCE
		is_jumping = true
else:
	#Jump
	if Input.is_action_just_released("Jump") and velocity.y < 0:
		velocity.y = velocity.y * JUMP_CUT_OFF_FACTOR
	
	#Double Jump
	if Input.is_action_just_pressed("Double Jump") and can_double_jump:
		velocity.y = JUMP_FORCE	
		can_double_jump = false
	
	#Buffered Jump pt. 1
	if Input.is_action_just_pressed("Jump"):
		buffered_jump = true
		JumpBuffer.start()
	

move_and_slide()

#Coyote Jump
var just_left_the_floor = not is_on_floor() and was_on_floor

if just_left_the_floor and velocity.y >= 0:
	coyote_jump = true
	CoyoteTimer.start()

Hey…i found a solution. Im sooooo happy at the moment. I just made a big mistake.
I used:
,direction = get_axis(“Left”, “Right”)
velocity.x = move_forward(velocity.x, Move_speed * direction, acceleration)
,
Thats why my walljump didnt work correctly.
My friction function would never be called because when direction = 0 ----> Movespeed = 0.