- Home /
Question by
AvatarusSwtor · Sep 22, 2013 at 07:45 PM ·
gameobjectchildtagactivation
Finding Gameobjects with tag and then deactivate it child
Hi I have on my scene 3 gameobjects with tag "Wrog" and thej all have 1 child element "zaznaczenie".
I want to create function with will find all gameobjects with tag Wrog and then set active=false on child element zaznaczenie. How can I accomplish this? Im trying with this, but no luck:
function odznacz_wszystkich()
{
//narazie to nic nie robi
for(var fooObj : GameObject in GameObject.FindGameObjectsWithTag("Wrog"))
{
//Debug.Log("Znaleziony:" + fooObj.name);
var zaz:Transform=fooObj.transform;
var zaz2:Transform=fooObj.transform.FindChild("zaznaczanie");
//Debug.Log("Znaleziony:" + zaz.name);
zaz2.active=false;
}
}
Comment
Answer by ArkaneX · Sep 22, 2013 at 09:40 PM
If zaznaczenie is the name of your child game object, then you have a mistake in FindChild - change a to e in zaznaczanie ;)
Your answer
![](https://koobas.hobune.stream/wayback/20220613114625im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
GameObjectWithTag Child 1 Answer
Access a child from the parent or other gameObject. 2 Answers
Can't Return the Tag of a Child Object 4 Answers
Raycast object tag check? 3 Answers