public void switchChar(CustomeNetworkBehavior old, int index) { GameObject gameObject = Instantiate(spawnPrefabs[index], old.gameObject.transform.position, old.gameObject.transform.rotation); playerPrefab = spawnPrefabs[index]; Destroy(old.gameObject); // OnServerAddPlayer(conn,gameObject.GetComponent<PlayerController>().playerControllerId); NetworkServer.ReplacePlayerForConnection(old.connectionToClient, gameObject, 0); }
void Start() { customeNetworkBehavior = GetComponent <CustomeNetworkBehavior>(); selectGun(); gun = 0; if (customeNetworkBehavior.isLocalPlayer) { UiManager = GameObject.FindWithTag("Manager").GetComponent <UIManager>(); StartCoroutine(update()); } }
public void switchChar2(CustomeNetworkBehavior old, string name) { GameObject gameObject = null; int index = 1; for (int i = 1; i < spawnPrefabs.Count; i++) { if (spawnPrefabs[i].name.Equals(name)) { index = i; gameObject = Instantiate(spawnPrefabs[i], old.gameObject.transform.position, old.gameObject.transform.rotation); } } playerPrefab = spawnPrefabs[index]; Destroy(old.gameObject); // OnServerAddPlayer(conn,gameObject.GetComponent<PlayerController>().playerControllerId); if (gameObject != null) { NetworkServer.ReplacePlayerForConnection(old.connectionToClient, gameObject, 0); } }
// Start is called before the first frame update void Start() { CustomeNetworkBehavior = this.GetComponent <CustomeNetworkBehavior>(); }
// Start is called before the first frame update void Start() { customeNetworkBehavior = this.GetComponent <CustomeNetworkBehavior>(); animator = GetComponentInChildren <Animator>(); }