as the title says
I have a number of game objects named PlanetA
I would like to get all of these into one GameObject array via a find function, how would I do that?
as the title says
I have a number of game objects named PlanetA
I would like to get all of these into one GameObject array via a find function, how would I do that?
I’d suggest using a tag rather than the name, and then you can do “var myObjectArray = GameObject.FindGameObjectsWithTag(“PlanetA”);”.
–Eric
Alright, thank you.
Another issue I’ve run into similiar to this is I am trying to get a global builtin array of components.
var planets: planetImpact[];
function Awake()
{
var planetObjects : GameObject[];
var impactArray = new Array();
planetObjects = GameObject.FindGameObjectsWithTag("planet");
for ( i=0; i < planetObjects.length; i++){
impactArray[i] = planetObjects[i].GetComponent("planetImpact");
}
var planets : planetImpact[] = impactArray.ToBuiltin(planetImpact);
}
This works. But the line
var planets : planetImpact[ ] = impactArray.ToBuiltin(planetImpact);
This is not assigning the js array to the global builtin array, but is rather assigning the js array to a builtin array local to the awake function. How would I go about assigning the js array to a global builtin array?
NEVERMIND
I figured it out
planets = impactArray.ToBuiltin(planetImpact);
:roll:
I know I know. That was stupid.