Preparing Your Player
Spawn an object over the network to represent each client's player.
Last updated
Spawn an object over the network to represent each client's player.
Last updated
For many games you will want to have a player object for each client. This guide will walk you through the process step by step.
Before You Begin Ensure that you're not in Play Mode in the Unity Editor. Making changes during Play Mode will not persist after exiting.
Create a Player Game Object
In the Unity Scene Hierarchy, create a new 3D object of type Capsule. Select the capsule in the Hierarchy and rename it to Player. In the Inspector, click on Add Component and search for NetworkObject. Add the NetworkObject component to the capsule.
Setup the Player Object for Spawning
Drag the player game object into the project window to turn it into a prefab, then delete the game object from the scene.
Select the NetworkManager in the scene and assign your new Player prefab into the Player Prefab field on the PlayerSpawner component.
Add Spawn Points
Create two empty Game Objects in the scene to act as spawn points. Position them where you'd like players to spawn on the map. Add these Game Objects as Transform references to the PlayerSpawner component in the Spawns list field.
Test the Player Spawning
Save the scene and press the Play button in the Unity Editor. As soon as the server and client starts you should see the a capsule spawning as the player object at the location of the first spawn point. To see another player spawn you can build and run the game and which will then automatically connect as a client to the editor. You should then see a second player capsule spawn for the second player at the second spawn point.
Alternatively, you can launch a second Unity Editor instance by using package or a third party package such as .