player_input.gd 653 B

12345678910111213141516171819202122232425
  1. extends MultiplayerSynchronizer
  2. # Set via RPC to simulate is_action_just_pressed.
  3. @export var jumping := false
  4. # Synchronized property.
  5. @export var direction := Vector2()
  6. func _ready():
  7. # Only process for the local player
  8. set_process(get_multiplayer_authority() == multiplayer.get_unique_id())
  9. @rpc("call_local")
  10. func jump():
  11. jumping = true
  12. func _process(delta):
  13. # Get the input direction and handle the movement/deceleration.
  14. # As good practice, you should replace UI actions with custom gameplay actions.
  15. direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
  16. if Input.is_action_just_pressed("ui_accept"):
  17. jump.rpc()