Add objects to array based off object name
Hey! So I'm trying to add objects, called "Node#" to an array, with the # being the order I want it in the array. As of now, I have this messy script
void Start()
{
nodeList[0] = GameObject.Find("Node0").transform;
nodeList[1] = GameObject.Find("Node1").transform;
nodeList[2] = GameObject.Find("Node2").transform;
etc etc ...
}
While it works, I want the array list to be variable based off the number of nodes I have loaded, if that makes sense.
Thanks for the help!
Comment
Your answer
Follow this Question
Related Questions
Moving spawned enemies randomly towards several pre-defined positions 1 Answer
transform.find exception if child does not exist 1 Answer
Transform.find Does not work 0 Answers
How I can assign an empty object to static (Transform) variable ?? 1 Answer
c# Getting Transforms from array made from FindGameObjectsWithTag 1 Answer