Controls
Contains functions for customizing camera/control schemes.
This module can only be used in Entity scripts.
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
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
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
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
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
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
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
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
setCameraLockOn(target, subject)
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.
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
getControlScheme(target)
Returns the control scheme value of the target player.
Parameters
- target — The target Player or client ID.
canControlCharacter(target)
Returns if the target player's character can be controlled.
Parameters
- target — The target Player or client ID.
canControlCamera(target)
Returns if the target player's camera can be controlled.
Parameters
- target — The target Player or client ID.
canJump(target)
Returns if the target player can jump.
Parameters
- target — The target Player or client ID.
canGlide(target)
Returns if the target player can use a glider.
Parameters
- target — The target Player or client ID.
canMount(target)
Returns if the target player can use a mount.
Parameters
- target — The target Player or client ID.
getCameraPosition(target)
Gets the view position assigned to the player's camera.
Parameters
- target — The target Player or client ID.
getCameraLookAt(target)
Gets the target look position assigned to the player's camera.
Parameters
- target — The target Player or client ID.
getCameraZoom(target)
Gets the zoom value assigned to the player's camera.
Parameters
- target — The target Player or client ID.
getCameraFollow(target)
Gets the id of the object the player's camera follows.
Parameters
- target — The target Player or client ID.
Enums
ControlScheme
- Adventure — value = 0
- ShooterFixed — value = 1
- Overview — value = 2
- Fixed — value = 3
- Custom — value = 4
- ShooterFree — value = 5
- Dialogue — value = 6
- LockOn — value = 7