How do I instantiate multiple GameObjects over Photon Network correctly?
Options
Hi
So I am building a procedural level and I am trying to instantiate multiple GameObjects over the Photon server.
I am just using the ConnectAndJoinRandom Script that Photon supplies as my Network manager.
then I instantiate all the GameObjects like so:
PhotonNetwork.Instantiate(gameObjectsToPlace[i].gameObjects.name, gameObjectsToPlace[i].posRots[j].position + transform.position, gameObjectsToPlace[i].posRots[j].rotation * rotationX, 0);
And it instantiates all the GameObjects over the network and then a minuet later it throws an exception:
Failed to Instantiate prefab: Cube. Client should be in a room. Current connectionStateDetailed: Disconnecting
And then all the gameObjects disappear.
Can someone please help?
So I am building a procedural level and I am trying to instantiate multiple GameObjects over the Photon server.
I am just using the ConnectAndJoinRandom Script that Photon supplies as my Network manager.
then I instantiate all the GameObjects like so:
PhotonNetwork.Instantiate(gameObjectsToPlace[i].gameObjects.name, gameObjectsToPlace[i].posRots[j].position + transform.position, gameObjectsToPlace[i].posRots[j].rotation * rotationX, 0);
And it instantiates all the GameObjects over the network and then a minuet later it throws an exception:
Failed to Instantiate prefab: Cube. Client should be in a room. Current connectionStateDetailed: Disconnecting
And then all the gameObjects disappear.
Can someone please help?
0
Comments
-
So I have tried changing it from Photon.Instantiate to Photon.InstantiateSceneObject like so:
if (PhotonNetwork.isMasterClient)
{
PhotonNetwork.InstantiateSceneObject(gameObjectsToPlace[i].gameObjects.name, gameObjectsToPlace[i].posRots[j].position + transform.position, gameObjectsToPlace[i].posRots[j].rotation * rotationX, 0, null);
}
It instantiates the objects but then disconnects and the objects disappear, even when I am a master client.
But still getting the same exception?
0 -
Is it because I have the PhotonNetwork.InstantiateSceneObject under an Update() method?0
-
Hi @markashburner,
please don't open separate threads about the same topic. It's actually hard to get the current state of the problem. I already answered to the other thread, but I want to add another hint here. Since you make something procedural, you should avoid creating the level with networked objects. Instead try to use a seed which you can share across the network which allows each client to generate the same level.0