Skip to main content

Timeline for Lag in Destroy() method

Current License: CC BY-SA 3.0

11 events
when toggle format what by license comment
Mar 26, 2017 at 16:04 comment added DMGregory @Krythic, it appears to me that you may be the one who misunderstands Unity's workings. The GameObject that our managed C# scripts reference is actually a wrapper linking to a corresponding piece of data in unmanaged code. When Unity decides to delete that backing object, it can do so with impunity. It then sets the managed GameObject into a special state where it compares as equal to null but is not actually null (generating MissingReferenceExceptions when you try to use it), until all references to it are cleared/go out of scope as per usual
Feb 12, 2017 at 11:58 vote accept Mihai Barbu
Feb 9, 2017 at 11:21 comment added Gnemlock @Krythic, the question specifically only asks about calling 'Destroy()' on the object. I think it is safe to assume that this functionality is the expected functionality when the asked reports "destroying the player". You can do this quite easily, in Unity. If your still confused, I can link some basic tutorials or examples that demonstrate this.
Feb 9, 2017 at 0:41 comment added Krythic You cannot "destroy" an object in a managed environment. The most Unity can do is set the object to null, along with every child entity it owns. This leads me to believe that your design is fatally flawed, much as your understanding is of how Unity works. I'm downvoting for blatant lack of personal research,
Feb 8, 2017 at 23:00 history edited Gnemlock CC BY-SA 3.0
removed tag (context of collision, but thats just meta); updated code with update from author; minor format and grammar
Feb 8, 2017 at 22:59 answer added Gnemlock timeline score: 1
Feb 8, 2017 at 19:52 comment added Mihai Barbu Thanks. Anyway , I changed my code to : public class DestroyScript : MonoBehaviour { public GameObject player; // Use this for initialization void Start () { } // Update is called once per frame void OnTriggerEnter(Collider otherObj) { if(otherObj.gameObject.tag == "Player") Destroy(otherObj.gameObject); }
Feb 8, 2017 at 19:45 comment added mrogal.ski It's because Destroy called on a GameObject will Invoke Destroy on each of the Components and Objects held by this GameObject try to make an Coroutine which will destroy Components one by one instead of all at once.
Feb 8, 2017 at 18:06 history edited Mihai Barbu CC BY-SA 3.0
deleted 3 characters in body
Feb 8, 2017 at 18:03 history edited House CC BY-SA 3.0
deleted 152 characters in body
Feb 8, 2017 at 17:59 history asked Mihai Barbu CC BY-SA 3.0