Sync materials between players?
Is it possible to sync materials between players? like, when a player changes color during the game, I want the other players to be able to see that. Maybe something to do with RPCs? If so, could someone please point me in the right direction?
Best Answers
-
I've now changed the MonoBehaviour to MonoBehaviourPunCallbacks and added this bit of script:
public override void OnPlayerEnteredRoom(Player newPlayer)
{
base.OnPlayerEnteredRoom(newPlayer);
pv.RPC("UpdatePlayerColor", RpcTarget.All);
}
and now I can detect when a player enters the room!
0 -
If each player gets a color, I would use Custom Player Properties to sync this.
0
Answers
-
Ah, I've partially figured it out. When the player spawns, it sends an RPC to every player in the room. This almost works, but here's the problem. A player enters the room. He sends an RPC to everyone in the room, but there aren't any players in the room. Another player joins. He sends an RPC, and the first player gets it and can observe the second player's color! But since the first player's RPC was wasted on "thin air" so to speak, the second player cannot observe the first player's color. I tried just putting an RPC call in the update loop so that every player is sending an RPC, to everyone, all at once, forever. This kind of worked, but as you can probably imagine, it slowed the game down. Now, the thing I want to know is if there's a way to detect when a player enters the room, so that the players only send RPCs when that happens, not in the update loop. I've seen OnPlayerEnteredRoom but that's for Photon Realtime, right? Is there a Photon PUN version of this?
0 -
I've now changed the MonoBehaviour to MonoBehaviourPunCallbacks and added this bit of script:
public override void OnPlayerEnteredRoom(Player newPlayer)
{
base.OnPlayerEnteredRoom(newPlayer);
pv.RPC("UpdatePlayerColor", RpcTarget.All);
}
and now I can detect when a player enters the room!
0 -
Why the RPC. Everyone knows the player entered and you don't pass a variable (yet?!) to the RPC. You can just update the color.
0 -
What do you mean? That was the problem: updating the color didn't sync.
0 -
If each player gets a color, I would use Custom Player Properties to sync this.
0 -
I've got it working, thanks for your help!
1