SetPlayerPosition
setPlayerPosition
Moves a connected player to an authoritative world position.
Syntax
bool setPlayerPosition(int playerId, number x, number y, number z [, number yaw = 0])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
playerId |
int |
yes | The connected player identifier. |
x |
number |
yes | World X coordinate in metres. |
y |
number |
yes | World Y coordinate in metres. |
z |
number |
yes | World Z coordinate in metres. |
yaw |
number |
no | Optional actor yaw in degrees; defaults to 0. |
Returns
Returns true when the authoritative move is accepted and queued for the client; otherwise returns false.
Examples
Move a player two metres along the X axis:
local position = getPlayerPosition(playerId)
if position then
setPlayerPosition(playerId, position.x + 2, position.y, position.z)
end
Notes
- Available only in server-side resource scripts.
- Coordinates use metres. The server converts them to Unreal units before sending the reliable control event.
- The player must already have supplied at least one valid movement snapshot.
- This function emits
onPlayerTeleportwhen accepted.