- Home /
How to distroy the script
Hi, first of all I'm sorry about my English !!
Q: Is there any way to destroy the script "DontDestroyOnLoad" at certain level ??
I attached the script on empty GameObject to play some music but the problem is that I want to stop the music at certain level by destroying the script !!
Answer by Rafes · Sep 24, 2011 at 03:43 PM
Destroy(ComponentName) works just like destroying game objects. Notice the docs show a rigid body being destroyed, which is a component just like your script: http://unity3d.com/support/documentation/ScriptReference/Object.Destroy.html
Answer by Naserano · Sep 24, 2011 at 06:09 PM
I got your point clearly, unfortunately I don't know anything about scripting. Can you please edit the script for me so the component will be destroyed if the player reached the level "whatever" .. Please I need this ):
function Awake () {
DontDestroyOnLoad (this);
}