How to instantiate prefab on every client's view ?

I create 2 clients : A ( Windows standalone) and B (Unity Play mode). In Photon Resources folder I put a Square prefab (already has PhotonView and TransformView component and code to move left/right according to keyboard). When 2 clients joined in same room then each client all load level to "Room" Scene. In this Scene there is a code at Start instantiate an instance of Square prefab with RED color if player is A and GREEN color if player is B. But when I run 2 clients and and join room and I see client B has Red and Green squares but client A has 2 Red Squares, I press keyboard to move square on client A and client B, they all move well synchronized. I don't understand: WHY THERE ARE 2 RED SQUARES in Client A ?

Here is the screenshot and my very small demo Unity Project:


  • Hi @Nguyen_Thanh_Tam,

    the situation is that you only have one prefab in your project which is fine so far. I haven't taken a detailed look at the project so the following points are just guesses from my side, so please feel free to correct me. When the player have joined a room, he automatically loads another scene. In this scene there is an object with an attached 'Spawner' component which actually instantiates the prefab - this is still okay so far. However setting the color in the same script is not synchronized and results in the behaviour you have described above. To apply color modifications to the instantiated prefab you can use a RPC call for example. This call can already contain the certain color as parameter. To see how RPCs are working I would recommend you taking a look at the RPCs and RaiseEvent documentation page.

    If you have further questions please feel free to ask.
  • You can use PhotonNetwork.Instantiate
Sign In or Register to comment.