Hi Everyone
I have this code I’m trying to alter to fit my game style but I’m having an issue.
What I want is once the player picks his or her team that will decide which Spawn area they will start in.So If they pick Red team they will Spawn where the red team should and the same idea with the blue team.
Here is the code that handles the choice. I got this code from http://www.M2H.nl)
private var chooseTeamInt = 0;
private var chooseTeamNames : String = [“Red”, “Blue”];
private var ffInt = 0;
private var ffNames : String = [“Off”, “On”];
private var chosenPlayerInt = 0;
if (serverGameTypeSelected != “DM”)
{
GUI.Label (Rect (110, 120, 150, 20), "Choose Team: ");
chooseTeamInt = GUI.Toolbar ( Rect (250, 120, 100, 20), chooseTeamInt, chooseTeamNames);
switch (chooseTeamInt)
{
case 0:
PlayerPrefs.SetString("playerTeam", "RedTeam");
break;
case 1:
PlayerPrefs.SetString("playerTeam", "BlueTeam");
break;
}
This is the code that handles the loading of the player when the game type is chosen.
void OnNetworkLoadedLevel()
{
GameObject[] spawnPoints = GameObject.FindGameObjectsWithTag("SpawnPoints");
Debug.Log("Spawns: " + spawnPoints.Length);
Transform spawnpoint = spawnPoints[UnityEngine.Random.Range(0, spawnPoints.Length)].transform;
Transform newTrans = Network.Instantiate(playerPref, spawnpoint.position, spawnpoint.rotation, 0) as Transform;
}