This commit is contained in:
2025-02-06 23:39:13 +01:00
parent a41cbaedad
commit 5d80182781
17 changed files with 209 additions and 38 deletions

19
MyChar.gd Normal file
View File

@@ -0,0 +1,19 @@
extends CharacterBody2D
@export var speed := 80.0 # px/s
@onready var sprite: AnimatedSprite2D = $sprite
var input_dir := Vector2.ZERO
func _ready() -> void:
$sprite.play("idle")
func _physics_process(_dt: float) -> void:
velocity = speed * input_dir.normalized()
move_and_slide()
if input_dir != Vector2.ZERO:
if sprite.animation != "walk":
sprite.play("walk")
elif sprite.animation != "idle":
sprite.play("idle")