As long as I can’t delete specific RPCs from the buffer, I’m not using any buffered RPCs or Network.Instantiate except for the player objects (otherwise the game builds up a large queue of network messages that are now irrelevant) – in general, I’ve gotten by fine just using RPCs for everything else.
Unfortunately I’m running into problems when trying to sync new players with other existing objects – I need to make sure new players have existing turrets in their scene.
When I try telling the new client to instantiate this object, I send the object’s viewID – this seems to be a problem. This new guy wasn’t here when the viewID was allocated, so it seems like he can’t use it? So how am I supposed to instantiate the turret on the new client and give it the same viewID it has on other clients?
I guess I could destroy and recreate every turret… but I’d like to avoid that and it seems like this shouldn’t be so hard… (it’d all be really easy, actually, if Network.Instantiate calls were removed from the buffer if that object was Network.Destroyed)
you can set the value of a networkview’s id directly. Just networkView.viewId = someId
Using this:
have the server keep an array of what’s currently spawned, and what the viewid that was allocated for each is
when a new player connects, tell them what to spawn, and send them also what the viewid is for each spawned object
connected player spawns said objects, and assigns the viewid that was sent to said spawned object’s networkview.
I think I already knew the stuff discussed in this thread – I’ve got it working fine apart from bringing new players up to speed. I was hoping to get confirmation that Unity3 still requires the ‘recreate everything’ workaround before implementing it myself, but I might do that today anyway.
This may be a silly question because my programming education was somewhat backward, but how would I get the numeric value of a networkViewID to save so I can have a value for “someId”? ParseInt from a networkViewID or something?
Because otherwise, I think I’m already trying to do what you’re suggesting (saving the allocated viewID as a NetworkViewID and trying to manually assign it later) – it works great if everybody’s already connected, but I’m having trouble with new clients (I think I’ll just have to recreate them all, like what is described in the link I posted)
Yeah I was already doing that (I describe that in my first post). I got it working but it doesn’t work with state synchronized networkView’s (no initial state), so I’m updating transform through RPC (I’ve read I can keep state synchronization if I recreate all the objects (for everyone) when a new client connects, but I figure just ditching state synchro will help network traffic.