Launching player works from the floor but not from the walls

Godot Version

Godot 4.2.1


The player should be able to click LMB, drag and release to launch a character in the air (kind of like in Angry Birds or in old Bowman 2 game) until he collides with wall or floor which should stop the movement and allow next launch.

But the proper launching seems to work only from the floor but not from the walls.

As you can see i tried printing “is_launching”, but it only prints when player is on floor.
Also when character touches the wall, seems like the code only allows to launch him in X direction, not allowing to launch further in the air (in Y direction)

p.s. tried using left/right raycast.is_colliding method instead of “on_the_wall” - same result.

My code:

extends CharacterBody2D

@onready var cat = $“.”

const SPEED = 120.0

var gravity = ProjectSettings.get_setting(“physics/2d/default_gravity”)

var drag_start: Vector2
var drag_end: Vector2

var launch_distance: float = 0
var launch_direction: Vector2
var launch_vector: Vector2

var is_dragging = false
var is_launching = false

func _physics_process(delta):
if is_launching:
print("is launching ", is_launching)

if Input.is_action_just_pressed("Left_Mouse"):
	is_launching = false
	drag_start = get_viewport().get_mouse_position()
	is_dragging = true

if Input.is_action_just_released("Left_Mouse") and is_dragging:
	drag_end = get_viewport().get_mouse_position()
	is_dragging = false
	is_launching = true
	launch_vector = drag_end - drag_start
	launch_direction = -launch_vector.normalized()
	launch_distance = launch_vector.length()
	if is_on_floor() or is_on_wall():
		velocity = SPEED * delta * launch_distance * launch_direction

if not is_on_floor():
	velocity.y += gravity * delta
	is_launching = false
if is_on_floor() and not is_launching:
	velocity.x= 0

if is_on_wall() and not is_launching:
	velocity.y = 0	


here is a gif of how it works so far: