private void CreatePlayers() { int pNum = PhotonNetwork.LocalPlayer.ActorNumber - 1; FaceoffPlayerManager playerManager = FindObjectOfType <FaceoffPlayerManager>(); playerManager.clientTeam = (TeamGroup)(pNum % 2); Vector3 spawn = pNum % 2 == 0 ? team1Spawn.transform.GetChild(pNum / 2).position : team2Spawn.transform.GetChild(pNum / 2).position; Vector3 rotation = pNum % 2 == 0 ? new Vector3(0, 90, 0) : new Vector3(0, -90, 0); GameObject p = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "FaceoffPlayer"), spawn, Quaternion.Euler(rotation)); p.GetPhotonView().RPC("SetTeam", RpcTarget.All, pNum % 2); }
public void PlayerDied(int actor) { TeamGroup team = GetComponent <Team>().team; // Notification if (actor != -1) { NotificationType notifType = NotificationType.Good; FaceoffPlayerManager pManager = FindObjectOfType <FaceoffPlayerManager>(); // If my client is the dead player if (photonView.IsMine) { notifType = NotificationType.Bad; } // Or if the dead player has a teammate who is my client else { IEnumerable <GameObject> teamMates = pManager.GetTeammates(gameObject, team); foreach (var mate in teamMates) { if (mate.GetPhotonView().IsMine) { notifType = NotificationType.Bad; break; } } } NotificationSystem.Instance.Notify(new Notification($"Player {actor} killed Player {photonView.ControllerActorNr}", notifType)); } if (photonView.IsMine) { Instantiate(deathUI); } // Hit all death events try { OnPlayerDeath?.Invoke(gameObject, team); } catch (Exception) { Debug.Log("Exception"); } if (photonView.IsMine) { // GetComponent<PlayerMotor>().normalCam = deathCam; GetComponent <PlayerMotor>().speed = 0; GetComponent <PlayerMotor>().speedModifier = 0; GetComponent <PlayerMotor>().sprintModifier = 0; GetComponent <PlayerMotor>().jumpForce = 0; UI.SetActive(false); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } if (photonView.IsMine) { PhotonNetwork.Destroy(this.gameObject); } }