x


delete parent or send message to parent?

Hey, how do i either delete the parent of an object from a script on the child OR send a true/false message to the parent?

plz JAVA :P

more ▼

asked Dec 23 '10 at 04:28 AM

Jason Hamilton gravatar image

Jason Hamilton
445 68 73 80

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

2 answers: sort voted first

Something like this:

var parent = transform.parent;
if (parent != null)
{
    Destroy(parent.gameObject);
}

or this:

var parent = transform.parent;
if (parent != null)
{
    parent.SendMessage("FunctionName", boolValue, SendMessageOptions.DontRequireReceiver);
}
more ▼

answered Dec 23 '10 at 05:09 AM

Mike 3 gravatar image

Mike 3
30.5k 10 65 252

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

// I think this is a bit more easier to send a message to parent :)

transform.root.gameObject.SendMessage ("AddPoint", 1);

more ▼

answered May 18 '12 at 12:25 AM

sunnykhan4u21 gravatar image

sunnykhan4u21
3 4 5 9

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

x3454
x764
x420
x409
x115

asked: Dec 23 '10 at 04:28 AM

Seen: 2691 times

Last Updated: May 18 '12 at 12:25 AM