- Home /
Simple Script Issue
Hello, I have a script that worked until I upgraded to Unity 3.2, and I cannot seem to find what is not working. Simply put, when the Projectile hits the object the scripts attached to, an explosion is instantiated ( this is working ) the object is destroyed ( also working ) and another unrelated object, in this case the "barrierToDestroy" is destroyed ( this isn't working ) I've tried everything I can think of but just can't get it to work. Any help is greatly appreciated, Thanks in Advance.
var explosion : Transform;
var barrierToDestroy : Transform;
function OnTriggerEnter(hit : Collider) { if(hit.gameObject.tag == "Projectile") {
Destroy (hit.gameObject); //This works Destroy (barrierToDestroy); //This is broken var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity); // This works Destroy (gameObject); //This works
}
}
Answer by Persona · Feb 18, 2011 at 12:21 AM
Try turning the barriertoDestroy into a gameObject.
Thank you, worked perfectly :) Thanks, for the quick reply too.
Your answer
