mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-05 15:30:07 +01:00
* Add player_state dictionary to manage player state names for FSM demo * Use a constant typed Dictionary of StringNames and update to Godot 4.5 --------- Co-authored-by: Aaron Franke <arnfranke@yahoo.com>
19 lines
552 B
GDScript
19 lines
552 B
GDScript
extends "res://player/player_state.gd"
|
|
# Collection of important methods to handle direction and animation.
|
|
|
|
func handle_input(input_event: InputEvent) -> void:
|
|
if input_event.is_action_pressed("simulate_damage"):
|
|
finished.emit(PLAYER_STATE.stagger)
|
|
|
|
|
|
func get_input_direction() -> Vector2:
|
|
return Vector2(
|
|
Input.get_axis(&"move_left", &"move_right"),
|
|
Input.get_axis(&"move_up", &"move_down")
|
|
)
|
|
|
|
|
|
func update_look_direction(direction: Vector2) -> void:
|
|
if direction and owner.look_direction != direction:
|
|
owner.look_direction = direction
|