Multiplayer
Makes the scene a multiplayer game. Put it on any entity (a “Game” entity is tidy). Host one with a Host Game button or Game.Network.Host(), and others join with Join Game or Game.Network.Join(“192.168.1.5”); in the editor, Play with Players starts several at once. The host runs the game; everyone sees the same world.
Each player gets their own copy of the Player entity, at a PlayerSpawn, moved by their own keys or controller, and Griff’s components (movement, weapons, attacks, health, pickups, building, strategy orders) work for every player. Cameras, the HUD and menus stay on each machine and follow that player’s own character.
Works with: PlayerSpawn (where players appear (on other entities)); Scoreboard (who’s playing, their scores and pings)
In a network game, each machine keeps its own entity with this on it: it isn’t sent.
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
maxPlayers: a whole number = 8. The most players in one game, the host included. (Field: a number.)port: a whole number = 7777. The network port the host listens on. Joining players use it too unless their address names another. (Field: a number.)player: text = “Player”. The entity each player plays as: one in the scene (the host plays that one, everyone else a copy) or a prefab. Empty gives players no character, as in a strategy game where each player commands a Faction. (Names an entity.) (Field: an entity’s name.)
teams: text = null. Team names, e.g. “Blue, Red”, for team games: players join the team with the fewest, play at a spawn for their team, and can’t hurt each other unless FriendlyFire is on. In a strategy game they’re the Faction teams players take: “Player, Enemy”. Empty is everyone for themselves. (Teams in order (as a list, one a line; as text, separated by commas). The Inspector lists them a row each to rename, add, take out and reorder.) (Names a team: this entity’s own, which other fields can name.) (Field: its own editor: Name List.)friendlyFire: true or false = false. Players on the same team can hurt each other. (Only used when teams is set.) (Field: on or off.)colorPlayers: true or false = true. Paint each player’s character their own color (their team’s, in a team game) so everyone can tell them apart: its sprite, or the sprites with a Team Color if it has any. (Field: on or off.)scoreKills: true or false = true. A point for the player who lands the blow that defeats another player’s character. (Field: on or off.)
Network
Section titled “Network”sendRate: a number = 30. How many times a second the host sends what changed. More is smoother, and uses more of the connection. (Field: a number.)viewDistance: a number = 0. How far from a player’s character (or camera) things are sent to them, in world units: for a big world with many players, like an MMO. 0 sends everything. Things with no picture (a score keeper) and tilemaps always go. (Field: a number.)smoothing: a number = 0.1. Seconds other players and moving things are shown behind the host, so they glide smoothly between updates instead of jumping. Your own character never waits: you move it yourself. (Field: a number.)rememberPlayers: true or false = false. Keep each player’s character as they left it (where it was, its health, inventory and score) and give it back when someone with the same name joins again, even in a later game: for persistent worlds. (Field: on or off.)exitScene: text = null. The scene to go back to when the connection to the host is lost or the host leaves, e.g. “Menu”. Empty restarts this one. (Names a scene.) (Field: a name.)
Scripts use it as Multiplayer: its methods, events and values that aren’t saved with the scene.