How do I enable or disable a object for all players?

Specifically looking for something like a light switch where if I click a button on the keyboard it will turn on a light. I'm pretty sure I have to use RPCs to do this but the photon documentation for that hasn't really helped.

I did manage to find one example on a discord server but it isn't really what I'm looking for but I will paste it in anyways. Here's the example.

photonView.RPC("DisableChildObject", PhotonTargets.AllBuffered, player, false);


[RPC]

void DisableObject(string ob, bool isActive)

{

GameObject.Find(ob).gameObject.SetActive(isActive);

}

Answers

  • I can think of a few ways to do this, let me know if you've already figured this out or you still need help