예제 #1
0
    void CreatePlayers()
    {
        // Create our players
        numPlayers = MatchSettings.numPlayers;
        if (numPlayers == 0 || selectScreen || mapSelect)    // Debug, for looping
        {
            MatchSettings.Reset();
            numPlayers = 4;
        }

        players  = new PlayerStats[numPlayers];
        controls = new Controls[numPlayers];
        for (int i = 0; i < numPlayers; i++)
        {
            Unique temp = Instantiate(playerPrefab, transform);
            if (temp == null)
            {
                Debug.LogError("Error creating player");
            }

            players[i]  = temp.GetComponentInChildren <PlayerStats>();
            controls[i] = temp.GetComponentInChildren <Controls>();
        }
    }