Hey.
I need to check if this gameobject is the child of any gameobject with tag (“xxx”).
this gameobject = the object to which the script is attached to.
I need that definition for define scalings and so on…
Up to now my try was it to check transforms with gameobjects name, but that does not work at all.
I hope you can help me here! Thank’s!
I don’t understand what you mean by ‘scaling’, but answering this specific question:
I need to check if this gameobject is
the child of any gameobject with tag
(“xxx”).
Walk up the parent chain and check each tag. Here is an untested function showing what I mean. It returns true if any parent has the tag specified:
function ChildOfObjectWithTag(tag : String) : boolean {
var t = transform.parent;
while (t != null) {
if (t.tag == tag) {
return true;
}
t = t.parent;
}
return false;
}