How can i Jump while sliding down the wall in a 2d platformer game?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatoLover
func jump():
	if Input.is_action_just_pressed("jump"):

		if is_on_floor() or hasDoubleJump:
			velocity.y=max_jump
			$Sprite.play("jump")
		if !is_on_floor():
			hasDoubleJump=false
	if Input.is_action_just_released("jump"):
		velocity.y=100
	if is_on_floor():  
		hasDoubleJump=true
		

func wallSlide():
	if is_on_wall() and (Input.is_action_pressed("left") or Input.is_action_pressed("right")):
		canJump=true
		if velocity.y>=0:
			velocity.y=min(velocity.y+wall_accl_slide,max_wallSLideSpeed)
		else:
			velocity.y+=gravity
func oppositeJump():
	if Input.is_action_just_pressed("jump"):
		if canJump==true:
			if is_on_wall() and Input.is_action_pressed("right"):
				velocity.x=-max_horizontalSpeed
			elif is_on_wall() and Input.is_action_pressed("left"):
				velocity.x=max_horizontalSpeed

here in opposite() function i tried to jump to the opposite wall
to the wall the player was holding.

You’re gonna have to put more context than just dumping your script.

Adab | 2023-01-13 11:14

hi…
srry for dumping the entire script i have edited the question.

potatoLover | 2023-01-13 11:34

Having the whole script is fine, what I meant is just having more context on what did you try and what was the result.

From what I see in your opposite() method, you set velocity.x which I assume is used in a move_and_slide() method somewhere else in the code. Where do you change velocity.x in your script other than here ? Depending on how you change this value your wall jump might not work.

Adab | 2023-01-13 21:09