Getting Reference to Player Objects at Network Game

I have some scripts at my network game how call the player Objects in theyer Start() functions. The problem is how i guss that the player is spawned at network after the scean start funcions are called so i get errors because the Player dont exist and the scripts gett NullPointer. How can i fix that ?

I guss i can just put this:

void Awake() {
    gameObject.SetActive(false);
}

in every script that uses the Player and set them to active from the Player Start() function but is there a better way to do this?

Found a good way by my self :slight_smile:

  public override void OnClientConnect(NetworkConnection conn) {
        ClientScene.Ready(conn);

        Object[] allObjects = Resources.FindObjectsOfTypeAll(typeof(GameObject));
        foreach (GameObject go in allObjects) {
            if (go.tag != "NetworkPlayer") {
                go.SetActive(false);
            }
        }

        ClientScene.AddPlayer(0);

        foreach (GameObject go in allObjects) {
            go.SetActive(true);
        }
    }