Is there a particular reason why you're doing the jump stuff during process and the other movement during physics_process? According to the documentary you should use move_and_slide only within _physics_process to ensure correct calculations. I'd recommend you to change your jumping-code to meet this "rule".
Your character is unable to move due to your DASH_KEYS check. You're changing the value but never set it back to 0. I came up with a solution but maybe there are some usecases I haven't tested :)
extends KinematicBody2D
const SPEED = 40
const SPRINT_SPEED = 200
# Time to double tap the left/right key in milliseconds (500 = 0.5 seconds)
const DOUBLE_TAP_TIME = 500
var is_sprinting = false
#variables for timekeeping
var threshold_right = 0
var threshold_left = 0
var difference = 0
var motion : Vector2
func _physics_process(delta):
# Reset the motion-Vector each frame
motion = Vector2.ZERO
# is_action_just_pressed returns "true" for only 1 frame
# if threshold_right is 0 (default case) set it to the current milliseconds and apply normal movement speed
if Input.is_action_just_pressed("ui_right"):
if threshold_right == 0:
threshold_right = OS.get_ticks_msec()
motion.x += SPEED
# if threshold_right is not 0, take the current milliseconds and subtract the value of threshold_right
# if the difference is smaller than our defined double tap time, set is_sprinting to true and apply sprint speed
else:
difference = OS.get_ticks_msec() - threshold_right
if difference <= DOUBLE_TAP_TIME:
is_sprinting = true
motion.x += SPRINT_SPEED
# is the action key still pressed and is_sprintig is true? keep up the sprinting speed, otherwise get back to normal movement speed
elif Input.is_action_pressed("ui_right"):
if is_sprinting:
motion.x += SPRINT_SPEED
else:
motion.x += SPEED
if Input.is_action_just_pressed("ui_left"):
if threshold_left == 0:
threshold_left = OS.get_ticks_msec()
motion.x -= SPEED
else:
difference = OS.get_ticks_msec() - threshold_left
if difference <= DOUBLE_TAP_TIME:
is_sprinting = true
motion.x -= SPRINT_SPEED
elif Input.is_action_pressed("ui_left"):
if is_sprinting:
motion.x -= SPRINT_SPEED
else:
motion.x -= SPEED
# Check if the threshold values are greater than 0 (set during is_action_just_pressed but the action was never pressed again)
# If they are greater than 0, check the difference again and reset the threshold-value if neccessary
if threshold_right > 0:
difference = OS.get_ticks_msec() - threshold_right
if difference > DOUBLE_TAP_TIME:
threshold_right = 0
if threshold_left > 0:
difference = OS.get_ticks_msec() - threshold_left
if difference > DOUBLE_TAP_TIME:
threshold_left = 0
#if the key (right/left) is released and the player was sprinting, set back the variable
if Input.is_action_just_released("ui_right") and is_sprinting:
is_sprinting = false
if Input.is_action_just_released("ui_left") and is_sprinting:
is_sprinting = false
# disable / enable horizontal flip depending on the movement.x-value, if the value is 0 keep the last state
if motion.x > 0:
$Sprite.flip_h = false
elif motion.x < 0:
$Sprite.flip_h = true
# finally apply the calculated motion
motion = move_and_slide(motion)
You still need to add the whole jumping stuff. But keep in mind to only apply the move_and_slide once at the end of the function. I hope this helps :)