- Home /
Question by
Mike Ledwards · Dec 02, 2010 at 02:18 PM ·
explosionimpact
scripting Impact explosion
I have a fireball type projectile and there is an explosion prefab, but how do i script it to explode upon impact with a collider?
Comment
Best Answer
Answer by Anton S. · Dec 02, 2010 at 03:14 PM
Attach this script to the fireball and add the explosion prefab to it.
public explosion : Transform;
function OnCollisionEnter(collision : Collision) {
Instantiate (explosion, transform.position, transform.rotation);
Destroy (this);
}