So, I'm connecting a script, for applying damage, and the function is on its own script, and I want it to destroy whatever object it is on... (Being a prefab).
So, what I'm wondering is how do you make a line of code that makes the gameobject that the script is connected to to destroy...
Like,
if(health <= 0)
{
//What to put in place of the _'s?
Destroy(________________);
}
Actually, wouldn't it be gameObject? From the Unity reference :
// Kills the game object
Destroy (gameObject);
// Removes this script instance from the game object
Destroy (this);
// Removes the rigidbody from the game object
Destroy (rigidbody);
// Kills the game object in 5 seconds after loading the object
Destroy (gameObject, 5);
// When the user presses Ctrl, it will remove the script
// named FooScript from the game object
function Update () {
if (Input.GetButton ("Fire1") && GetComponent (FooScript))
Destroy (GetComponent (FooScript));
}