x


Access a child from the parent or other gameObject.

If I have a script that checks for a tag in a gameobject and I want to access a child in the gameObject with the tag what do I do? PLZ HELP

PLEASE DON'T ANSWER SOMETHING STUPID SUCK AS "Why don't you put the tag on the child?" or something like that, If you're gonna answer ANSWER MY QUESTION, I don't wanna know how to do it other way PLEASE UNDERSTAND I need this.

more ▼

asked May 08 '11 at 08:25 PM

Thomas Paniagua gravatar image

Thomas Paniagua
41 15 17 19

chill down... It's okay to ask for an exact answer to your question but do you have to do it in such an agitated manner? Greetz, Ky.

Aug 07 '11 at 09:31 AM SisterKy
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I think there's several ways to solve your problem, the easiest being:

use

Transform mychildtransform = gameobjectwithmytag.transform.FindChild(mychildname);

and then

mychildgameobject = mychildtransform.gameObject;

Of course there's many ways to get your gameobjectwithmytag object. The simplest being

GameObject.FindGameObjectWithTag

or GameObject.FindGameObjectsWithTag if there's many (of course you'll need to iterate through them and extract the one you're interested in).

more ▼

answered Aug 07 '11 at 09:23 AM

roamcel gravatar image

roamcel
1.2k 37 40 44

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

x2075
x418
x407
x321
x151

asked: May 08 '11 at 08:25 PM

Seen: 2883 times

Last Updated: Aug 07 '11 at 09:31 AM