- Home /
Question by
valtteri_m · Apr 26, 2015 at 06:59 PM ·
javascriptparentchildaccess
Access parents other child from other other child
Id want so that I could acces Parent's Child1's script from Child2
Parent
-Child1
-Child2
I have this kind of line of script but it sadly doesnt work..
GameObject.Find("/transform.root/Weapon").GetComponent("WeaponGUI").WeaponGUI.Add110();
please help!
Comment
Best Answer
Answer by Chris333 · Apr 26, 2015 at 07:21 PM
Hi,
try to use something like that.
Script on child02:
int indexOfChild = 0;
GameObject child01 = transform.parent.gameObject.transform.GetChild(indexOfChild).gameObject;
child01.GetComponent<...>()......
http://docs.unity3d.com/ScriptReference/Transform.GetChild.html
thanks! I had to convert it into unityscript but it seems to work :D
Ah sry i posted it in c# ;-) Could you mark the answer as correct than. ty :-)
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Accessing a variable from a child object and pass it to the parent 2 Answers
Removing specific child objects 1 Answer
Trouble accessing child 3 Answers