x


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);


}
more ▼

asked Dec 21 '11 at 10:45 PM

Persona gravatar image

Persona
246 74 85 96

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
#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

more ▼

answered Dec 21 '11 at 11:36 PM

Lo0NuhtiK gravatar image

Lo0NuhtiK
3.5k 1 9 39

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2097
x888
x356

asked: Dec 21 '11 at 10:45 PM

Seen: 646 times

Last Updated: Dec 21 '11 at 11:39 PM