PUN2 Chess game instantiation problem

Options
Hi, I made a chess game, it works perfectly in single player and wanted to add a multiplayer mode, so I found PUN2. Originally all chess pieces are instantiated on start, When I tried not to change it, so I just added a photon view and photon transform view classic components and built the game, when I move a piece it shows on one side only. So I tried PhotonNetwork.Instantiate and it worked on both sides well, but it instantiated every piece twice, so there are two white teams and two black teams.. Then I tried PhotonNetwork.InstantiateSceneObject and it didn't instantiate every team twice, and it transmitted the movement on both sides, but I can move the pieces on only one side, on the other client it just doesn't work. Also when using InstantiateSceneObject all pieces have "Controlled Locally" turned off in the photon view component.. while using PhotonNetwork.Instantiate all pieces have it turned on and on the doubled pieces it is turned off. Problem: How can I use PhotonNetowrk.Instantiate without doubling teams. or how can I use PhotonNetwork.InstantiateSceneObject but control the ownership of teams, so that one client owns white team and other owns black team, or even both I think I can work around it if both can control both teams.. Thanks :D.

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Voltonik,

    Thank you for choosing Photon!

    So I tried PhotonNetwork.Instantiate and it worked on both sides well, but it instantiated every piece twice
    You are probably calling Instantiate from both clients which is wrong. You need to call it once per client. Make sure to do a check before instantiating based on IsMasterClient or ActorNumber etc.