instantiate on new player w/o buffered RPCs - also question about AllocateViewID

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.

http://forum.unity3d.com/threads/10723-Bringing-newly-Client-Player-quot-up-to-Speed-quot?p=75852&viewfull=1#post75852 doing more research, it seems indeed to have to recreate the turrets…

Is this still a bug in Unity3? (I’m still on 2.6 for now)

I don’t think its necessarily a bug, though yes, it would be nice if network.destroy removed instantiated items from the buffer.

And nothing changed in the networking department on the move to unity v3

http://forum.unity3d.com/threads/56900-Is-trying-to-simulate-Network.Instantiate-worth-the-labor

You “may” skip the beginning, it becomes more interesting later.

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)

var NVIDToSave : NetworkViewID;

NVIDToSave = networkView.viewID;

?

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.