local_input.gd 517 B

12345678910111213
  1. class_name LocalInput
  2. extends Node
  3. # Sends commands from a local device
  4. signal dir_changed(new_dir: Vector2)
  5. signal main_action(pressed: bool)
  6. func _unhandled_input(event: InputEvent) -> void:
  7. if event.is_action("main"):
  8. main_action.emit(event.is_pressed())
  9. elif event.is_action("move_left") or event.is_action("move_right") or event.is_action("move_back") or event.is_action("move_forward"):
  10. var dir: Vector2 = Input.get_vector("move_left", "move_right", "move_back", "move_forward")
  11. dir_changed.emit(dir)