Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

GameObject.Destroy = NetworkServer.Destroy

Discussion in 'Connected Games' 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:
    3
    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