Persona
1
How do I change the position of all the gameobjects in an Array?
function CanCheck(){
var arr: Array = new Array();
Check = GameObject.FindGameObjectsWithTag("Can");
for (var checking: GameObject in Check){
if(checking.GetComponent("CanScript").Flip){
arr.Push(checking);
checking.position.x += 4;
}
}
Cans = arr.ToBuiltin(GameObject);
}
#pragma strict
@HideInInspector
var myObjects : GameObject[] ;
function Start(){
myObjects = GameObject.FindGameObjectsWithTag("Can") ;
}
function CanCheck(){
for (var check : GameObject in myObjects){
check.transform.position.x += 4 ;
}
}
that will move "All" of them anyway ...NOTE: you'll need to call the CanCheck function somewhere... just to clarify