er2.unbindKey ▲ 42

Available from Easy Red 2 2.1.1

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 TypeDescription
voidThis function doesn't return anything

Parameters

ParameterTypeDescription
1stringThe 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")

Back to Scripting API