er2.unbindKey 42
Removes the press and release callbacks of a key. When the last key is unbound the keyboard is no longer watched. er2.resetCallbacks() and the end of the battle unbind every key.
Return value
| Return Type | Description |
|---|---|
| void | This function doesn't return anything |
Parameters
| Parameter | Type | Description |
|---|---|---|
| 1 | string | The key, as a Unity KeyCode name. |
Examples
A key that calls artillery
-- F5 fires a barrage on the player's position, once every 30 seconds
local nextBarrage = 0
er2.setCallback("barrage", function()
if er2.time() < nextBarrage then
er2.print("Artillery is reloading")
return
end
nextBarrage = er2.time() + 30
local player = er2.getPlayer()
if player ~= nil then
local p = player:getPosition()
er2.explosion(vec3(p.x, p.y, p.z + 25), 400, 20, 12)
end
end)
er2.bindKey("F5", "barrage")
-- the key is released when the mission no longer needs it
-- er2.unbindKey("F5")