How to transfer generated world from the master client over the network
Box
✭
The first problem i have is keeping the parent/child relationships between the instantiated gameObjects over the network. The generated world consists of 100 regions, which in turn consist of 25 gameObjects each.
My second problem is that the scriptableObjects that i have assigned to each gameObject disappears over the network.
I generate the world only if the client is the master client. And i have successfully Instantiated the world over the network by instantiating each gameObject with "PhotonNetwork.InstantiateRoomObject()". After each instantiation i assign the gameObject a parent, which works on the master client. However, over the network this comes with the problems stated above, the parent/child relationships are gone, and all the values on the instantiated gameObject are null.
What i would love to do, is just copy and paste the hierarchy on the master client to the other clients, but i can't find any such solutions to these problems.
And here i am, with no idea what to do or what direction to take. After some research i'm pretty sure i should be using RCPs. I tried calling the method as an RCP instead, with everyone as a target, but instead nothing was instantiated.
I appreciate any help at all, i'm in quite a bind right now.
My second problem is that the scriptableObjects that i have assigned to each gameObject disappears over the network.
I generate the world only if the client is the master client. And i have successfully Instantiated the world over the network by instantiating each gameObject with "PhotonNetwork.InstantiateRoomObject()". After each instantiation i assign the gameObject a parent, which works on the master client. However, over the network this comes with the problems stated above, the parent/child relationships are gone, and all the values on the instantiated gameObject are null.
What i would love to do, is just copy and paste the hierarchy on the master client to the other clients, but i can't find any such solutions to these problems.
And here i am, with no idea what to do or what direction to take. After some research i'm pretty sure i should be using RCPs. I tried calling the method as an RCP instead, with everyone as a target, but instead nothing was instantiated.
I appreciate any help at all, i'm in quite a bind right now.
0
Comments
-
For parenting i tried
photonView.RPC("SetParent", RpcTarget.AllBuffered, tile.transform, tilesGO.transform); [PunRPC] private void SetParent(Transform child, Transform parent) { child.parent = parent; }
Instead oftile.transform.parent = tilesGO.transform;
But then nothing is instantiated instead0 -
Fixed parenting issue with
photonView.RPC("SetParent", RpcTarget.AllBuffered, tile.GetPhotonView().ViewID, tilesGO.GetPhotonView().ViewID); [PunRPC] private void SetParent(int childViewID, int parentViewID) { Transform child = PhotonNetwork.GetPhotonView(childViewID).gameObject.transform; Transform parent = PhotonNetwork.GetPhotonView(parentViewID).gameObject.transform; child.parent = parent; }
0