allows for defining of input actions and assigning them to different keys
func _input(event):
if event.is_action_pressed("my_action"):
print("my_action occurred!")
Built in type, contains basic information
Event ID, device index
Events are received at the OS level and then spread to nodes through the SceneTree
In general, we want specialized child nodes to handle and consume particular events, while their ancestors provide more generalized behavior.
Events v. Polling
func _input(event):
if event.is_action_pressed("jump"):
jump()
func _physics_process(delta):
if Input.is_action_pressed("move_right"):
# Move as long as the key/button is pressed.
position.x += speed * delta
captured with InputEventKey
can check for modifier combinations using boolean properties on the event
func _input(event):
if event is InputEventKey and event.pressed:
if event.scancode == KEY_T:
if event.shift:
print("Shift+T was pressed")
else:
print("T was pressed")
captured with InputEventMouse