Hi @rods012,
Thank you for your questions.
- Does the name “child” affect what is being retrieved from pathPrefab?
The name does not affect anything. You could rename the variable to blah
, abc
or cats
, and the loop program would still work.
- If not, by writing “in pathPrefab.transform” it knows only to get the children?
Yes, because that’s how the Unity programmers defined it. See the description of the Transform class in the API.
- If I wanted to get the transform of the pathPrefab GameObject itself in a “foreach” loop how would I do it, or would I never use a “foreach” loop for this situation?
Why would you want to access the Transform object of the pathPrefab
in this(?) foreach-loop? pathPrefab.transform
references the Transform object of the game object referenced by pathPrefab
.
- Off of that, if I wanted to get the transform component from both the pathPrefab AND its children, how would I write that?
I’m not telling you the solution directly because I believe that you are able to find it yourself based on what I wrote in answers #1 to #3. If not, please let me know.
Have your questions been answered?
See also:
- Forum User Guides : How to mark a topic as solved