motion.gd 530 B

12345678910111213141516171819
  1. extends "res://state_machine/state.gd"
  2. # Collection of important methods to handle direction and animation.
  3. func handle_input(event):
  4. if event.is_action_pressed("simulate_damage"):
  5. emit_signal("finished", "stagger")
  6. func get_input_direction():
  7. var input_direction = Vector2(
  8. Input.get_axis(&"move_left", &"move_right"),
  9. Input.get_axis(&"move_up", &"move_down")
  10. )
  11. return input_direction
  12. func update_look_direction(direction):
  13. if direction and owner.look_direction != direction:
  14. owner.look_direction = direction