- Home /
Question by
atrupb · Dec 09, 2020 at 11:36 AM ·
networkingphotonunity multiplayer
need help with players and GOs
[PunRPC]
void impostorCheckScriptMethod()
{
foreach (Player player in PhotonNetwork.PlayerList)
{
if (player.CustomProperties.ContainsValue("impostor"))
{
player.GetComponent<impostorScript>().enabled = true;
this.photonView.tag = "impostor";
}
}
}
how can i access a specifics players gameObject?
Comment
Answer by atrupb · Dec 09, 2020 at 12:22 PM
fixed. if anyone needs help with this here's how:
first, on your script which u use to instantiate playerObjs add this to your class classifcation: (name of script): MonoBehaviourPunCallbacks, IPunInstantiateMagicCallback
then add this
public void OnPhotonInstantiate(PhotonMessageInfo info)
{
info.Sender.TagObject = this.gameObject;
}
then in the script where u want to use gameObject add this:
GameObject playerr = (GameObject)player.TagObject;