Players.SetCamera

Declaration

Players.SetCamera(number PlayerID, Vector3 PositionOffset, Vector3 RotationOffset)

Description

Sets position and rotation camera offsets respectively to PositionOffset and RotationOffset for a specific player.

--Retrieves all players
local allPlayers = Players.GetAll();

--Sets the first player's camera
Players.SetCamera(allPlayers[1], V3(0, 6, 7.6), V3(25, 0, 0));

Declaration

Players.SetCamera(number PlayerID, TargetPlayer Mode, Vector3 Origin, Vector3 PositionOffset, Vector3 RotationOffset)

Description

Sets position and rotation camera offsets respectively to PositionOffset and RotationOffset for specific players, depending on the Mode. If using Mode set to Closest or Furthest, the Origin parameter will be used as the point of reference, otherwise Vector3.zero can be passed.

Check TargetPlayer for all possible Mode values.

--Retrieves all players
local allPlayers = Players.GetAll();

--Sets the camera for all the other teams than player 1's team
Players.SetCamera(allPlayers[1], TargetPlayer.OtherTeams, Vector3.zero, V3(0, 6, 7.6), V3(25, 0, 0));

--Sets the camera for everyone else than player 2
Players.SetCamera(allPlayers[2], TargetPlayer.Others, Vector3.zero, V3(0, 6, 7.6), V3(25, 0, 0));

--Sets the camera for the furthest player to the provided position
Players.SetCamera(0, TargetPlayer.Furthest, V3(2, 1, 2), V3(0, 6, 7.6), V3(25, 0, 0));

Declaration

Players.SetCamera(Dictionary<number> PlayerIDs, Vector3 PositionOffset, Vector3 RotationOffset)

Description

Sets position and rotation camera offsets respectively to PositionOffset and RotationOffset for specific players.

--Retrieves all players
local allPlayers = Players.GetAll();

--Sets the camera for everyone
Players.SetCamera(allPlayers, V3(0, 6, 7.6), V3(25, 0, 0));

--Sets different camera offsets for player 1 and 3 specifically
Players.SetCamera({allPlayers[1], allPlayers[3]}, V3(0.5, 0, 14), V3(0, 180, 0));

Note

Player IDs must be whole numbers.

Keep in mind the Player IDs aren't necessarily ordered. Players can join and leave in the lobby, potentially several times, increasing their ID, which is why using Players.GetAll is advised if you want to target a player at a specific slot.

You can also pass Player objects instead of numbers as IDs.

If there are several players playing on the same device, and the camera gets set for one of them, it will set the camera for every player on that device.

This does not affect the FPS gamemode camera.