Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Problem with finding compnent of immidate children

$
0
0
Hi all im having problems finding the components of immediate children. Im trying to make a "power" system that starts at one parent object at say power 10, then as it goes through its children (all with the same script) they divide up the power. transform.GetComponentsInChildren() will not work because firstly it calls its own LocalPower script even though it is not a child, and secondly it calls all of the sub children. I learnt this enough from google. so next i tryed to use foreach (Transform child in transform) { nNode = child.transform.GetComponent (); } However not all of its child objects have the script, as only power 'nodes' and things that use power use the script. I tried to make a list and only add nNode if it found the script but could not find a way to do that- and im feeling pretty dicy about the whole thing. First post, im a total noob im afraid, thank you!

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>