Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.Networking;
- public class TeamManager : NetworkBehaviour {
- public static TeamManager instance;
- static int playerCount;
- void Awake()
- {
- if(instance == null)
- {
- instance = this;
- DontDestroyOnLoad(gameObject);
- }
- else
- {
- DestroyImmediate(gameObject);
- return;
- }
- }
- [Server]
- public static void SetPlayerTeam(GameObject newPlayer)
- {
- var player = newPlayer.GetComponent<NetworkPlayer>();
- player.teamNumber = (int)Mathf.Repeat(playerCount, 2);
- playerCount++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement