kittik
September 2, 2015, 10:54am
1
I am trying to work out how to find a child object. The parent object being called someObject in the example below.
exampleGameObject = GameObject.Find ("someObject").GetComponent<Transform>();
Would “someParentObject.someChildObject” be a correct way of finding the child object, or is there a different way of doing it?
Thank you.
Parentobject.tranform.getchilds
1 Like
kittik
September 2, 2015, 11:14am
3
I have fixed the issue.
I was over-thinking how to find the Child. someParentObj.someChildObj was not required. Just naming the Child without referencing the Parent works fine.
exampleGameObject = GameObject.Find ("someChildObject").GetComponent<Transform>():
Kiwasi
September 2, 2015, 11:21am
4
Transform.Find is better for searching children.
GameObject.Find will search the entire hierarchy. Transform.Find is limited to children.
1 Like