Reputation: 69
Edit: Changed arrays to be enabled into just objects for better readability.
Currently I'm using Photon and have a OnPlayerPropertiesChanged function calling an RPC in the player script to change the player's model. What model they have depends on the team that's stated in their custom properties. The two teams are "citizens" and "angels". I want the Citizen Model to show up when a person's team property is "citizen", and the same for property of "angel". Code snippets below:
GameManager:
public override void OnPlayerPropertiesUpdate(Player target, ExitGames.Client.Photon.Hashtable changedProps)
{
if (changedProps.ContainsKey("team"))
{
var targetPhotonView = (PhotonView)target.TagObject;
targetPhotonView.RPC("ChangeTeamObjs", target, changedProps);
}
}
PlayerController:
[PunRPC]
public void ChangeTeamObjs(PhotonHash changedProps)
{
switch (changedProps["team"].ToString())
{
case specString:
citizenModel.SetActive(true);
angelModel.SetActive(false);
break;
case citiString:
citizenModel.SetActive(true);
angelModel.SetActive(false);
break;
case angelString:
citizenModel.SetActive(false);
angelModel.SetActive(true);
break;
default:
Debug.Log("ChangeTeamObjs() | Unknown team! | " + PhotonNetwork.LocalPlayer.NickName);
break;
}
ClientServerEnabling();
}
Currently, each person's model changes correctly on their own screen, but both models on other players are enabled on local player's screens. How can I setup my code to have the other clients' models appear/disappear on a person's screen when the OnPlayerPropertiesUpdate() is called?
Upvotes: 2
Views: 1827
Reputation:
I replied on your other questions (PUN Changes affect local players only, not other clients) with the similar issue, don't call rpc to a specific target, instead, set your rpc target to ALL:
https://doc.photonengine.com/en-us/pun/v2/gameplay/rpcsandraiseevent#targets__buffering_and_order
Upvotes: 2