x


Destroy the child instantiated object

i instantiated then made it a child so its position goes with the parent, but i wanted to destroy it when the parent and child collides with another object

here is my script,

var liquid : ParticleEmitter; var fluidflow : GameObject; var shaker : GameObject;

function OnCollisionEnter(theCollision : Collision){

if(theCollision.gameObject.name == "Cube") { water = Instantiate(liquid, fluidflow.transform.position, transform.rotation); water.transform.parent = transform; } else if(theCollision.gameObject.name == "Cube3") { Destroy(); } }

more ▼

asked Feb 05 '12 at 04:11 AM

charnew gravatar image

charnew
31 15 18 23

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

1 answer: sort voted first

You need to call Destroy( gameObject ), with gameObject as parameters. The seems ok.

more ▼

answered Feb 05 '12 at 05:54 AM

Berenger gravatar image

Berenger
11k 12 19 53

(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:

x1677
x764
x423
x411

asked: Feb 05 '12 at 04:11 AM

Seen: 739 times

Last Updated: Feb 05 '12 at 05:54 AM