extends CharacterBody2D
@export var speed = 100
@export_range(0, 1) var damping_factor := 0.6
func get_move_vector():
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
return input_direction
func move_player(delta : float):
if get_move_vector() == Vector2.ZERO:
# Damp Players Velocity if no Input
self.velocity = self.velocity * (1 - min(1, damping_factor * 60 * delta))
else:
# Set Players Velocity to the Input Direction in the Players Speed
self.velocity = get_move_vector() * speed * delta * 60
# Update The Players Physics Calculations
self.move_and_slide()
pass
func _physics_process(delta : float):
move_player(delta)