Meteor Explosion, Destroy on Impact

Hi Guys,

First off, I know this is a simple question, and I have tried many tactics to get this to work, but I can’t seem to get this working properly. I have been using the “Detonator-Insanity” Prefab to be the effect, but I get nothing.

So, what I want to happen is a meteor to fall out of the sky, explode on impact with the terrain, destroy itself, and once it explodes, I want to start a new reaction where it releases toxins and other interesting things.

I really only need help with the meteor exploding on impact and destroying itself. I use JS. I’m hoping for some code examples, as I have tried all the examples that I could find, and yet I still had no success.

Thank you for your help guys.

I wouldn’t recommended this method, but it’ll probably work. Colliders would be a better choice.

#pragma strict

public var minimumYPosition : float = 0f;
public var nextPrefabToLoad : GameObject;

function Update () {
	if (this.transform.position.y < minimumYPosition)  
	{
		if (nextPrefabToLoad != null) {
			GameObject.Instantiate(nextPrefabToLoad, transform.position, transform.rotation);
		}
		Destroy(this.gameObject);
	}
}

Edit

I don’t know what a detonator is, a prefab that plays an animation clip? What does Expode() do? Where is the detonator, on the meteor or the explosion insanity? There’s just not enough to go by on.

function Update () {
	if (this.transform.position.y < minimumYPosition)
	{
		if (nextPrefabToLoad != null) {
			var explosion : GameObject = GameObject.Instantiate(nextPrefabToLoad, transform.position, transform.rotation);
			if (explosion.GetComponent("Detonator") != null) {
				explosion.GetComponent("Detonator").Explode();  //detonator on explosion insanity    				
			}
		}
        //gameObject.GetComponent("Detonator").Explode();  // detonator on meteor
		if (this.renderer.enabled == true) Destroy(this.gameObject, 60f);
            this.renderer.enabled = false;
	}
}

Not sure if I ever had a problem now. The explosion worked, it was just so small that I couldn’t see it from the distance I was looking toward it. I created a camera and followed the meteor, and I saw it explode. Thank you all for taking the time to assist me.