Purpose of Destroy()

posted to: Animation Challenge

I see that Destroy() has a delay of 2f seconds. I tried setting that to 0 and then realized it's probably to allow the sound to play before the object is destroyed. OK. But then the object is hanging around for 2 seconds after the sound plays. So I see that in GemBounce, this is accounted for by keying MeshRenderer.enabled.

With MeshRenderer.enabled keyed, what's the point of having Destroy() here? Just to clear out memory?

  • Jonathan Gonzalez(jgonzalez) replied

    Disabling the mesh renderer just ensures it is not rendered on screen. By destroying the game object you remove it entirely from the game and free up the memory it was using.