unnamed-topdown-game/scripts/playerController.gd

20 lines
563 B
GDScript3
Raw Normal View History

2026-04-02 21:08:20 +00:00
extends CharacterBody2D
@onready var animationPlayer = $AnimatedSprite2D
2026-04-28 00:23:25 +00:00
const SPEED = 150
2026-04-02 21:08:20 +00:00
func _process(_delta):
2026-04-28 00:23:25 +00:00
velocity = Input.get_vector('moveLeft', 'moveRight', 'moveUp', 'moveDown') * SPEED
2026-04-02 21:08:20 +00:00
move_and_slide()
2026-04-28 00:23:25 +00:00
if Input.is_action_pressed('moveUp'):
animationPlayer.play('walk_up')
elif Input.is_action_pressed('moveDown'):
animationPlayer.play('walk_down')
elif Input.is_action_pressed('moveLeft'):
animationPlayer.play('walk_left')
elif Input.is_action_pressed('moveRight'):
animationPlayer.play('walk_right')
2026-04-02 21:08:20 +00:00
else:
animationPlayer.stop()