25 lines
501 B
GDScript
25 lines
501 B
GDScript
class_name Player
|
|
extends CharacterBody2D
|
|
|
|
|
|
@export var walk_speed: float
|
|
|
|
@export_group("Internal References")
|
|
@export var _animations: AnimationPlayer
|
|
|
|
|
|
var is_stunned := false
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
if is_stunned:
|
|
pass
|
|
else:
|
|
var input_dir = Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
|
|
velocity = input_dir * walk_speed
|
|
if input_dir.is_zero_approx():
|
|
_animations.play(&"idle")
|
|
else:
|
|
_animations.play(&"walk")
|
|
|
|
move_and_slide()
|