Players.Launch
Declaration
Players.Launch(number PlayerID, Vector3 Position, number Speed)
Description
Launches the specified player towards Position with Speed. Launching works similar to the Launcher tile.
--Launches the second player towards the center of the map
local allPlayers = Players.GetAll();
local world = World.GetSettings();
Players.Launch(allPlayers[2], V3(world.Width / 2, 1, world.Height / 2), 1);
Declaration
Players.Launch(number PlayerID, TargetPlayer Mode, Vector3 Origin, Vector3 Position, number Speed)
Description
Launches the specified player(s) towards Position depending on the Mode with Speed. 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. Launching works similar to the Launcher tile.
Check TargetPlayer for all possible Mode values.
--Launches other team members of the specified player
local allPlayers = Players.GetAll();
Players.Launch(allPlayers[1], TargetPlayer.OtherTeamMembers, Vector3.zero, V3(2, 1, 5), 1);
--Launches the furthest player from the provided point, PlayerID doesn't matter
local point = V3(2, 1, 3);
Players.Launch(0, TargetPlayer.Furthest, point, V3(2, 1, 5), 1);
Declaration
Players.Launch(Dictionary<number> PlayerIDs, Vector3 Position, number Speed)
Description
Launches the specified players towards Position with Speed. Launching works similar to the Launcher tile.
--Launches everyone towards a certain position
local allPlayers = Players.GetAll();
Players.Launch(allPlayers, V3(2, 1, 5), 1);
--Launches only the players that have enough bombs
local toTeleport = {};
for i, player in ipairs(allPlayers) do
if player.BombsTotal > 5 then
table.insert(toTeleport, player);
end
end
Players.Launch(toTeleport, V3(2, 1, 5), 1);
--Launches only the first two players
Players.Launch({allPlayers[1], allPlayers[2]}, V3(2, 1, 5), 1);
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.