Search Unity

Can I seriously not remove a specific Network.Instantiate from the RPC buffer?

Discussion in 'Multiplayer' started by J_P_, Sep 28, 2010.

  1. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    It seems Network.Instantiate is only useful for permanent objects (or player objects that you destroy when they leave) -- otherwise you're going to have an RPC buffer growing out of control.

    For example, my game lets the player fire missiles -- I have these missiles created with Network.Instantiate (so that their movement can easily be synced across all clients) and they typically don't last too long before being destroyed. Unfortunately, all these missiles are in the buffer so when a new player connects, the server sends Network.Instantiate calls for all those missiles that have long been destroyed. The new client spawns hundreds of missiles that have already been destroyed.

    I could also buffer an RPC to destroy these missiles, but that would be an incredible amount of wasted network traffic that would surely cause problems the longer the server has been running and storing an ever-increasing number of buffered RPC calls.

    So... what are my options?

    Option 1: To just avoid Network.Instantiate? Instantiating and syncing missiles using just RPC calls is going to be a pain.
    Option 2 [edit: Option 2 doesn't seem feasible because apparently we're limited to 32 network groups]: To assign each and every missile to it's own network group? So that I can Network.RemoveRPCsInGroup for that single Network.Instantiate? Is that even feasible?

    Seems like there should be a Network.Instantiate that just didn't buffer anything... or something like Network.Destroy that also removed RPCs for that object. Or am I just missing something?
     
    Last edited: Sep 28, 2010
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    from the manual
     
  3. cerebrate

    cerebrate

    Joined:
    Jan 8, 2010
    Posts:
    261
    I've had a similar problem as you have. I've basically assigned separate groups for separate types of items, then remove the rpcs for those item types per player. This only really helps when individual players instantiate their own items.

    What you can do is, using resources.load, pass strings with rpc calls for what people should 'network instantiate', and then have the server keep an array of strings of what is currently instantiated. 'network destroy' would cause everyone to destroy that specific network view, then have the server remove it from the array of what is currently made. People joining would cause the server to send them the array of what needs to be instantiated.
     
  4. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Yeah, in that example they remove ALL the RPCs (because they're changing levels). I need to remove specific ones.

    But earlier today I did finish my RPC method to emulate network.instantiate without buffer, so I've found a workaround.
     
    Last edited: Sep 28, 2010