(for reference this is a top down 2d game prototype thing)
i'm using the _physics_process() function with move_and_slide() like i'm supposed to, but even though my speed constant is set to 750, my character moves incredibly slow for whatever reason.
extends CharacterBody2D
class_name player
const SPEED = 750
const DASHSPEED = 0.1
const DASHDURATION = 0.2
const DASHCOOLDOWN = 0.5
var isDashing = false
var canDash = true
@export var isPlayerNear = false
func _physics_process(delta):
if !isDashing:
velocity = Input.get_vector("left", "right","up", "down") * (SPEED * delta)
move_and_slide()
func _process(_delta):
if isPlayerNear:
canDash = false
else:
canDash = true
func _input(event):
if event.is_action_pressed("action") and canDash:
if velocity != Vector2.ZERO:
StartDash()
func StartDash():
isDashing = true
canDash = false
var dashDirection = velocity.normalized()
velocity = dashDirection * (SPEED * DASHSPEED)
await get_tree().create_timer(DASHDURATION).timeout
StopDash()
func StopDash():
isDashing = false
canDash = false
velocity = Vector2.ZERO
await get_tree().create_timer(DASHCOOLDOWN).timeout
canDash = true
my previous solution was scaling everything down but it feels unorthodox to have to scale everything down to 0.03 and below just to make really high speed values work properly. what i gather from this is that it's either a really high speed value or really small assets, and i was wondering if i'm doing anything wrong because that would be really odd if that was the case.