Files
godot-demo-projects/2d/finite_state_machine/player/states/motion/motion.gd
Yaxian 1d8fa9c44d Add player_state dictionary to manage player state names for FSM demo (#1143)
* 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>
2025-10-01 21:33:27 -07:00

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