x


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

    }
}
more ▼

asked Feb 18 '11 at 12:16 AM

John G gravatar image

John G
1 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Try turning the barriertoDestroy into a gameObject.

more ▼

answered Feb 18 '11 at 12:21 AM

Persona gravatar image

Persona
261 76 85 97

Thank you, worked perfectly :) Thanks, for the quick reply too.

Feb 18 '11 at 12:27 AM John G

Remember to mark the answer correct.

Feb 18 '11 at 04:57 AM Persona
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x785
x130

asked: Feb 18 '11 at 12:16 AM

Seen: 345 times

Last Updated: Feb 18 '11 at 12:16 AM