Instantiate player on connection.

Im trying to Instantiate a player when someoen connects using this, but nothing seems to hapend in “OnPlayerConnected”, any ideas what i am doing wrong? Im new to Networking, or unity at all.

public class PlayerSpawnScript : NetworkBehaviour
    public GameObject Player;
    void OnPlayerConnected(NetworkPlayer player)
        Debug.Log("Player ID is " + Network.player.ToString());

On the network manager there’s a Spawn info dropdown with a tag “Player prefab”. you should use that to instantiate player clients.

Another note is that if you need to Instantiate objects on the fly, like bullets for example, you need to use Network.Spawn(gameobj); to get it to instantiate on the server and be registered with any other clients that are connected to your game.

I’d advise reading the tutorial Here if you’re completely new to Unity Networking.