0
\$\begingroup\$

I use Unity and Photon for the multiplayer. I Instantiate my gameObjects using this method :

void LoadGameObject(PhotonPlayer player,bool isMaster)
 {
  if (isMaster)
  {
    GameObject baby = PhotonNetwork.InstantiateSceneObject(babies[0].name, 
    babies[0].transform.position, Quaternion.identity, 0,null);
    baby.SetActive(true);
    Debug.Log("playerpref created on " + player.ID); 
  }
  else
  {
   //Nothing for the moment
  }
}

I call the method in "OnJoinedRoom()" and "OnPhotonPlayerConnected(PhotonPlayer other)", but when the second player join the room, he can't see the gameObjects because they aren't activated on his scene.

Any Idea of the mistake ?

\$\endgroup\$
  • 1
    \$\begingroup\$ It looks like you've got your prefab deactivated initially, requiring an explicit call to SetActive(true) to activate it. But I don't see where you call SetActive on the non-master instances — can you show us this? \$\endgroup\$ – DMGregory Mar 5 at 18:17
  • 1
    \$\begingroup\$ Thanks for your help, it was right. I just activated my GameObjects before instantiation because I didn't need to keept it inactive, and now it works fine. \$\endgroup\$ – GameDevF7 Mar 6 at 10:37
  • 1
    \$\begingroup\$ Great! If you've solved your problem, be sure to post your solution as an Answer below. \$\endgroup\$ – DMGregory Mar 6 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.