Catch-22 With Network Views and RPCs

Hey all,

I’m trying to avoid Network.Instantiate, but I find myself facing a catch-22 without it.

In order to tell the clients which NetworkViewID to use for my main RPC-sending-object, I need to be able to send the client an RPC. But to send an RPC the NetworkViewIDs must already be the same on the client and server… So this doesn’t even seem possible without at least one Network.Instantiate.

Or is there another way to go about this?

Add NetworkView to your network script gameObject and NetworkViewID will be same because u will build it. u do not need to use Network.Instantiate.

How is that the case? If I call Object.Instantiate(prefabX) on the server and Object.Instantiate(prefabX) they will start with an unassigned NetworkViewID and if I call AllocateViewID() then they are by no means guaranteed to be the same ID and I will get errors trying to send RPCs.

It seems to me I need to use Network.Instantiate to make the initial object and go from there. Alternatively, I can just leave them as NetworkViewID.unassigned and they will work (both have ID 0), but then if I set anything else as unassigned I come up against conflicts (this behavior is actually what I’ve now been trying to fix).

So, maybe I misunderstood? Or is there something else I can do?

u can put prefab in scene and build with it so they will have same networkViewID. u do not need Object.Instantiate and Network.Instantiate in this case.

if u do not want it u can use Object.Instantiate(prefabX) in server and client and they will have same (assigned) networkViewID if there are not other NetworkView components on scene. Test this, both should work.

Prefabs/objects in a scene that have network views attached BEFORE compile time, (so parts of the map, game managers, etc, that you don’t instantiate) have synced networkviewid’s, without requiring synchronization of any kind on your part.

Excellent, thank you.