Search Unity

GameObject.Destroy = NetworkServer.Destroy

Discussion in 'Multiplayer' started by SteamPunkPro2, Jun 16, 2017.

  1. SteamPunkPro2

    SteamPunkPro2

    Joined:
    Jun 8, 2013
    Posts:
    29
    After much experimenting its become clear to me that calling GameObject.Destroy on a networked object on the host is the same thing as calling NetworkServer.Destroy; for some very complex reasons I really dont want to go into explaining right now I dont want this. I want to be able to destroy the objects when I want, where I want, not when unity decides to send the message to the clients. Is there a way to prevent this event from being sent when calling GameObject.Destroy? Also its pretty annoying this is undocumented behavior I lost three days debugging this.
     
  2. apkdev

    apkdev

    Joined:
    Dec 12, 2015
    Posts:
    283
    Random necroanswer: UNET source hints that NetworkServer.Destroy() is called by NetworkIdentity in the OnDestroy handler[1]. NetworkIdentity is a sealed class so there's little hope in overriding that behavior. One thing to try could be removing the NetworkIdentity component on the clients, which should stop them from being destroyed by the server.

    [1] https://bitbucket.org/Unity-Technol...ewer=file-view-default#NetworkIdentity.cs-282