Skip to main content

Players

A player is a human or bot who is able to send inputs into the game to control it.

Spawning players

The SpawnEachPlayer function defines the main behavior of players in the game. It takes a block of code (a subblock) as an argument, which should be used to initialize the player entity. For example, it could create a hero unit for the player to control, and display some helpful messages to the player to get them started.

pub fn Example() {
SpawnEachPlayer owner {
// Initialization code for the player goes here
}
}

Spawning bots

The SpawnBot function causes a bot player to join the game. Any SpawnEachPlayer hooks will run first on the new bot player entity, then SpawnBot's subblock will be run with the same bot player entity. This can be used to specialize the bot player further, if necessary.

The IsHuman function can be used to determine whether a player entity is a human or a bot.

The DespawnBot function can be used to force a bot player to leave the game.

Eliminating players

The Eliminate function can be used to signal that a player has been eliminated from the current game. In a battle royale, this could mean when a player dies and will not come back. Eliminated players will be changed from colored to grey on the Scoreboard to help players keep track of who is still in the game. The engine is also constantly optimizing the network latency for only the players who are still in the game, and so eliminating players will improve the experience for the remaining players.