Controls
Contains functions for customizing camera/control schemes.
Functions
setControlScheme(target, controlScheme, resetRotation)
Sets the control scheme (camera and controls).
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - controlScheme — The ControlScheme to set.
- resetRotation — A boolean that determines whether the camera rotation should be reset (optional).
Example
Change the camera and control scheme to "fixed shooter".
function onStart()
Controls.setControlScheme(Players.All, ControlScheme.ShooterFixed)
end
Result
setPlayerControls(target, enablePlayerControls)
Enables or disables player controls like movement/weapons.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - enablePlayerControls — A boolean that enables or disables player controls.
Example
Disable player controls.
function onStart()
Controls.setPlayerControls(Players.All, false)
end
Result
setCameraControls(target, enableCameraControls)
Enables or disables control of the camera.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - enableCameraControls — A boolean that enables or disables camera controls.
Example
Disable camera controls.
function onStart()
Controls.setCameraControls(Players.All, false)
end
Result
setJumpControls(target, enableJumpControls)
Enables or disables jump control.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - enableJumpControls — A boolean that enables or disables jump controls.
Example
Disable jump controls.
function onStart()
Controls.setJumpControls(Players.All, false)
end
Result
setGlideControls(target, enableGlideControls)
Enables or disables glide control.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - enableGlideControls — A boolean that enables or disables glide controls.
Example
Disable glide controls.
function onStart()
Controls.setGlideControls(Players.All, false)
end
Result
setCameraPosition(target, position)
Sets the position of the camera.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - position — A Vector3 of the position to move the camera.
Example
Set up a top-down view of the world.
function onStart()
Controls.setCameraPosition(Players.All, {0,30,0})
Controls.setCameraLookAt(Players.All, {0,-1,0})
end
Result
setCameraLookAt(target, position)
Rotates the camera to look at the specified position.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - position — A Vector3 of the position to rotate the camera to look at.
Example
Set up a side view of the world.
function onStart()
Controls.setCameraPosition(Players.All, {30,0,0})
Controls.setCameraLookAt(Players.All, {-10,0,0})
end
Result
setCameraFollow(target, subject)
Sets the current camera to follow another player.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - subject — Entity or Player to follow.
Example
Follow the last player that joins the world.
function onPlayerJoin(player)
Controls.setCameraFollow(Players.All, player)
end
setCameraAxis(target, axis)
Rotates the camera around the player.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - axis — A Vector2 where X is between 0 and 360 degrees, and Y is between 0 and 1.
setCameraZoom(target, zoom)
Zooms the camera.
Parameters
- target — Either the target Player, client ID of the target player, or
Players.All
to target all players. - zoom — How far the camera is to the player.
- Min: 0
- Max: 1
Example
Zoom in the camera.
function onStart()
Controls.setCameraZoom(Players.All, 0)
end
Result
isDesktopLayout(target)
Returns true if using desktop layout.
Parameters
- target — Either the target Player, or client ID of the target player.
Returns
A boolean.
Example
Show a different text if is using desktop layout.
function onPlayerJoin(clientId)
if Controls.isDesktopLayout(clientId) then
Hud.console.write("Use keyboard and mouse to move!")
else
Hud.console.write("Use the on-screen buttons to move!")
end
end
Enums
ControlScheme
- Adventure — value = 0
- ShooterFixed — value = 1
- Overview — value = 2
- Fixed — value = 3
- Custom — value = 4
- ShooterFree — value = 5
- Dialogue — value = 6