Input actions and gamepad
An action is a name (pular) bound to keys and gamepad buttons. The code asks for the action, not the key.
function onUpdate(self) self.hspeed = axis("esquerda", "direita") * 2 if pressed("pular") then self.vspeed = -4 end if held("atirar") then spawn("Bullet", self.x, self.y, "Instancias") endendvoid onUpdate() override { hspeed = axis("esquerda", "direita") * 2; if (pressed("pular")) vspeed = -4; if (held("atirar")) spawn<Bullet>(x, y, "Instancias");}Create and change actions
Section titled “Create and change actions”Project › Project settings… › Input actions. A new project (Empty template) comes with:
| Action | Keyboard | Gamepad |
|---|---|---|
esquerda |
←, A | d-pad ←, stick ← |
direita |
→, D | d-pad →, stick → |
cima |
↑, W | d-pad ↑, stick ↑ |
baixo |
↓, S | d-pad ↓, stick ↓ |
pular |
Space | A |
acao |
X, Enter | X |
- The first connected gamepad is used; it can be plugged in while the game runs.
- An action that does not exist shows up once as an error in the Output.
- Gamepad button names and keys are in Input.
