I have a weird problem that only shows up with multiple clients (1 client-server, 2 clients). When client 2 connects, it Network.Instantiates() a player class object. That class object then calls (in it’s Awake() method) some initialization RPCs. The problem is, these things are happening out of order on the 2 clients. The RPCs arrive before the Network.Instantiate on the clients (so, Client A instantiates its player, the server then sends the init RPCs out, but on Client B, the RPCs get there first and fail because the object doesn’t exist yet, then the Instantiate shows up).
I’ve checked the detailed Network logging, which is how I figured this out, and that’s exactly what happens. Am I missing something? How can an RPC that is only called in the Awake method of an object arrive before that object is even created? It almost seems as though the Server gets the Insantiate command, buffers the RPCs, and then adds the Instantiate command to the buffer at the end of the frame (which would explain the results I’m seeing).
Can anyone confirm that is how Network.Instantiate works? Kind of at my wits end and getting ready to ditch Network.Instantiate in favor of my own command, but am hoping I’m just confused. Thanks for any help you can give.
Summary:
Client A calls Network.Instantiate()
Server calls some initializing RPCs in the Awake method of the instantiated object
Client B recieves the RPCs before the Network.Instantiate, and errors out because the networkView doesn’t exist yet.
Result is, the server player is fine on both clients, and both clients are fine on the server. Client A sees Client B as being uninitialized, and Client B sees Client A as uninitialized.
-Sean