private void SpawnPlayer() { string playerResource = ""; if (playerTeam == Unit.Team.Red) { playerResource = "Player Cube"; } else if (playerTeam == Unit.Team.Blue) { playerResource = "Player Cube Blue"; } GameObject playerGo; if (PhotonNetwork.IsConnected) { playerGo = PhotonNetwork.Instantiate( playerResource, spawnLocation.position, Quaternion.identity ); } else { playerGo = Instantiate( Resources.Load <GameObject>(playerResource), spawnLocation.position, Quaternion.identity ); } if (playerGo) { target = playerGo; player = playerGo.GetComponent <PlayerCube>(); } }
private void OnTriggerEnter(Collider other) { if (!PhotonNetwork.IsConnected || photonView.IsMine) { if (other.tag == "Player") { PlayerCube player = other.GetComponent <PlayerCube>(); if (player && player.team != ownerTeam) { player.Hurt(damage); player.KnockBack(transform.rotation * knockbackVector); Die(); } } else { Die(); } } }