Events vs Polling

Godot offers two ways to handle input: event-based (reacting when input happens) and polling (checking input state each frame).

Event-Based: _input()

Called once when the input occurs. Best for:

  • Button presses (jump, shoot, interact)
  • Menu navigation
  • Any "on press" action
gdscript
123456
func _input(event):
    if event.is_action_pressed("jump"):
        jump()
    
    if event.is_action_pressed("shoot"):
        fire_bullet()

Polling: Input singleton

Check every frame. Best for:

  • Continuous movement
  • Held buttons
  • Analog stick input
gdscript
123456
func _physics_process(delta):
    if Input.is_action_pressed("move_right"):
        position.x += speed * delta
    
    if Input.is_action_pressed("sprint"):
        speed = sprint_speed
💡 Unity Comparison

_input() is like Unity's OnButtonDown events, while Input.is_action_pressed() is like Input.GetKey().