I’m trying to add nodes to an Array but the nodes need to be within a certain range. I tried this to see if I could achieve this:

Collider[] colls = Physics.OverlapSphere(AI.position, distance);
    	foreach (Collider col in colls){
			nodes = GameObject.FindGameObjectsWithTag("Node");
		}

I knew it wouldn’t work, so what I tried to do was individually add each node inside the foreach:

Collider[] colls = Physics.OverlapSphere(AI.position, distance);
    	foreach (Collider col in colls){
			nodes.Add(col);
		}

And I made ‘nodes’ an ArrayList. Unfortunately though, it kept adding the same nodes over and over again until I had hundreds of the same nodes inside my ArrayList. How should I FindGameObjectsWithTag inside a certain range?

Simply change the tag after it’s made it into the list. You should consider using a collider set to trigger instead if this has to run every frame.

http://unity3d.com/support/documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html

theres an example code there …hope it helps