- Home /
Question by
Jason Hamilton · Dec 23, 2010 at 04:28 AM ·
javascriptdestroyparentchilddelete
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
Comment
Best Answer
Answer by Mike 3 · Dec 23, 2010 at 05:09 AM
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);
}
Answer by sunnykhan4u21 · May 18, 2012 at 12:25 AM
// I think this is a bit more easier to send a message to parent :)
transform.root.gameObject.SendMessage ("AddPoint", 1);