How to make a character2d bounce/reflect off of stuff

Godot Version

godot 4.2

Question

I have a mode in my platformer that makes the character move in a straight line, not effected by gravity. I want the character to bounce off of all objects in the “reflect” group. I’ve tried some get_bounce type stuff but can’t seem to get it to work. Here’s the code that handles this mode. Any help is appreciated.

if wave_on == true and not is_on_floor():
				if input_direction.length_squared() > 0.1:
					# Update last_direction when there is input
					last_direction = input_direction.normalized()
					rotation = input_direction.angle() + 1.55
					input_enabled = false
					if input_direction.length_squared() <0.3:
							last_direction = input_direction.length_squared() + 1
					
					#wave mode deactivation
					for index in get_slide_collision_count():
						var collision = get_slide_collision(index)
						if collision.get_collider().is_in_group("surface"):
							wave_mode_off()
							wave_enabled = false
						
						
					if Input.is_action_just_released("wave"):
						wave_mode_off()
						
				else:
					# If input_direction.length() <= 0, use the last direction
					input_direction = last_direction
					
						
				velocity = input_direction * wave_speed
				
			else:
					last_direction = input_direction.normalized()
					rotation = 0
					input_enabled = true

When you collide with a wall, use the get_wall_normal().reflect(velocity) function to obtain the reflection vector.

Like this? It isn’t working. Maybe I’m putting it in the wrong place?

for index in get_slide_collision_count():
						var collision = get_slide_collision(index)
						if collision.get_collider().is_in_group("surface"):
							wave_mode_off()
							wave_enabled = false
						if collision.get_collider().is_in_group("surface"):
								get_wall_normal().reflect(velocity)
					if Input.is_action_just_released("wave"):
						wave_mode_off()
						
				else:
					# If input_direction.length() <= 0, use the last direction
					input_direction = last_direction
					
						
				velocity = input_direction * wave_speed
				

I apologize, I made a mistake earlier. Below is a correct example:

@tool
extends CharacterBody2D

@export var direction: Vector2 = Vector2.ZERO:
	set(value):
		direction = value

func _physics_process(delta: float) -> void:
	if is_on_wall():
		direction = -velocity.normalized().reflect(get_wall_normal())
	velocity = direction * 30
	move_and_slide()

I want it to be able to reflect off of all sides, not just the walls. I’m not sure I understand your code block either.

Essentially I have this line of code that controls the velocity.
velocity = input_direction * wave_speed
The var input_direction is a vector2.
The godot docs have a code for bullet reflection, which is the same type of reflection I want, I just can’t figure out how to implement it into my specific code. The velocity * delta causes the character speed to be way too high, and it still isn’t reflecting

var collision = move_and_collide(velocity * delta)
	if collision:
		velocity = velocity.bounce(collision.get_normal())