void SpawnPlayers() { PlayerInfo[] playerInfos = characterSelect.GetPlayerInfos(); int team = 0; int playerNum = 0; int teamNum = 0; bool lookUp = false; Color spawnColor = Color.white; Texture2D playerTex = null; Vector3 spawnPos = transform.position; Quaternion spawnRot = Quaternion.identity; int team1Count = playerInfos.Count(r => r.teamIndex == 0) + 1; // starts at the number of players on the first team int team2Count = 0; for (int i = 0; i < playerInfos.Length; i++) { // Uses of player num: // control player // control character select // display character select // spawn players playerNum = playerInfos[i].playerIndex; teamNum = playerInfos[i].teamIndex; team = playerInfos[i].teamIndex; spawnPos = transform.position; playerTex = characterSelect.GetPlayerTex(playerInfos[i].texIndex); if (team == 0) { team1Count--; lookUp = true; spawnColor = team1Color; spawnPos += -Vector3.right * 4f * team1Count; spawnPos += Vector3.up * 3f; spawnRot = Quaternion.identity; } else { team2Count++; lookUp = false; spawnColor = team2Color; spawnPos += Vector3.right * 4f * team2Count; spawnPos += -Vector3.up * 3f; spawnRot = Quaternion.Euler(0f, 0f, 180f); } GameObject wormObj = WormManager.instance.CreateWorm(spawnPos, lookUp, playerNum, teamNum, spawnColor, playerTex).gameObject; wormObj.transform.rotation = spawnRot; wormObj.transform.parent.name = "P" + playerNum; wormObj.name = "Worm"; wormObj.GetComponentInChildren <SpriteRenderer>().color = spawnColor - new Color(0.2f, 0.2f, 0.2f, 0f); } }