Here is the code I am working with, as the title states the dash in the physics_process function sends the player way up vertically, I'd say about 10 times their height, while the horizontal dash makes them move 1 times their width. Trying to figure out why.
The Characterbody2d script:
(```)
extends CharacterBody2D
const SPEED = 100.0
const JUMP_VELOCITY = -150.0
const PUSHBACK = -400
const GRAVITY = 400
const WALL_GRAVITY = .8
var CAN_DASH = true
var DASH_COUNT = 1
@onready var dash := $dash
func _physics_process(delta: float) -> void:
var direction := Input.get_axis("Left", "Right")
var DASH_DIRECTION := Input.get_axis("Up","Down")
# Add the gravity.
if not is_on_floor() and !dash.DASHING:
velocity.y += GRAVITY * delta
if DASH_COUNT > 0:
CAN_DASH = true
else: CAN_DASH = false
if is_on_floor():
CAN_DASH = true
# Handle jump.
if Input.is_action_just_pressed("Jump") and is_on_floor() and !dash.DASHING:
velocity.y = JUMP_VELOCITY
if direction and !dash.DASHING:
velocity.x = SPEED * direction
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if is_on_wall() and Input.is_action_just_pressed("Jump"):
if Input.get_axis("Left","Right"):
velocity.y = JUMP_VELOCITY
velocity.x = direction * PUSHBACK
if is_on_wall() and !is_on_floor() and Input.get_axis("Left","Right"):
velocity.y *= WALL_GRAVITY
if Input.is_action_just_pressed("Dash") and CAN_DASH:
!dash.DASHING
!CAN_DASH
velocity += Input.get_vector("Left", "Right","Up","Down") * dash.DASH_SPEED
dash.start_dash(dash.DASH_DURATION)
move_and_slide()
(```)