- Home /
Question by
Mattivc · May 21, 2010 at 10:17 PM ·
javascriptgameobjectarraytags
Find and store gameObjects in a array
How i can find all gameObject with a certian tag in the scene and store them in a array?
Comment
Best Answer
Answer by qJake · May 21, 2010 at 10:23 PM
One line:
GameObject[] objects = GameObject.FindGameObjectsWithTag("myTag");
Note: Code is C#
http://unity3d.com/support/documentation/ScriptReference/GameObject.FindGameObjectsWithTag.html
Going to sound stupid, but what's the equivilent of this line in Javascript? guessing it's var object : GameObject[] = GameObject.FindGAmeObjectsWithTag("$$anonymous$$yTag"); but didn't see an exact reference for it when it came to arrays...
Answer by NightShade2109 · Mar 10, 2013 at 07:17 PM
var objects : GameObject[];
function Start()
{
objects = GameObject.FindGameObjectsWithTag("Tag");
}