- Home /
Question by
Persona · Dec 21, 2011 at 10:45 PM ·
gameobjectpositionarrays
Change Gameobject in Array's position
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);
}
Comment
Best Answer
Answer by Lo0NuhtiK · Dec 21, 2011 at 11:36 PM
#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
Your answer
Follow this Question
Related Questions
Find one inactive player (gameobject) 2 Answers
GameObject Array 1 Answer
How To Get A Reference To All Nearby GameObjects? 1 Answer