PlayerSpawner
The Player Spawner component can be used to spawn a game object for a client once they connect to the game.
Description
The PlayerSpawner component in FishNet is responsible for spawning player objects for clients when they connect to the server. You set the player prefab using the inspector or via the SetPlayerPrefab
method. You can also define an array of spawn points (Transforms) for players (the Spawns array). If no spawn points are set, the prefab’s own position and rotation are used. You also have access to the OnSpawned
event that fires on the server when a player is spawned.
Check out the API page for specific fields and events here.
Settings

⚙️ Player Prefab
This is used to select the prefab this component will instantiate for clients when they connect to the server.
⚙️ Add to Default Scene
This is used to add a client to the active scene when no global scenes are specified through the FishNet SceneManager. This is important because FishNet doesn't force a client to start in the same scene as the server, so FishNet needs to be told if a client should observe a specific scene and receive information about the Network Objects in that scene.
⚙️ Spawns
This is a list of GameObject Transforms that the PlayerSpawner will use as locations to spawn the players at. It will use them in order, one after another, looping once it reaches the final one. If none are given, then it will use the prefab's base position.
Last updated