Search Unity

NetworkServer.Destroy(), without destroying object (for pooling)

Discussion in 'Multiplayer' started by Shinyclef, Jun 19, 2015.

  1. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Hello,

    There is some information I received in the beta forums about Network.Destroy() in relation to object pooling:
    However, it looks to me like this is in fact destroying the object on the server and is therefore not suitable for pooling.
    To get around this, I implemented my own messages and sent that to the clients instead so the object could be returned to pool on both server and client. The object was not being destroyed on server, however I believe I'm missing pieces of the puzzle as I eventually get duplicate observer errors. I think I need to somehow tell unity that this object is no longer network managed until I re-spawn it (with my custom spawn handler).

    I'd like to know more about what NetworkServer.Destroy() does behind the scenes, so that I may replicate all of the network object clean-up functionality without having the object destroyed on the server.

    Thank you.
     
  2. any_user

    any_user

    Joined:
    Oct 19, 2008
    Posts:
    374
    Yeah, it would be nice to have something like NetworkServer.Unspawn() to use it before locally destroying the object on the server. Right now it's not completely transparent what's happening, and given that we have to call NetworkServer.Spawn after instantiation, it would be logical to manually "unspawn" the object before destroying it.
     
  3. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    Yes, this fix will be in an upcoming patch release.
     
    liortal likes this.
  4. Shinyclef

    Shinyclef

    Joined:
    Nov 20, 2013
    Posts:
    505
    Are there any recommended manual steps I can take to 'disconnect' the object from the network so that it may be respawned again later?

    Edit: Actually it's ok. If I do a workaround, I may as well just Instantiate and Destroy until the patch fix arrives. Thanks for your clarification :)
     
    Last edited: Jun 20, 2015
  5. gsus725

    gsus725

    Joined:
    Aug 23, 2010
    Posts:
    250
    Calling Destroy() on all these networked projectiles instead of pooling them is going to murder my frame rate. I had pooling for projectiles with the legacy networking and I remember that with the pooling the frame rate would be like 150 and without it it was devastated down to like 20 because they are very rapid fire projectiles.