- Home /
Using a number array?
Hi, I'm using FindGameObjectsWithTag to create an array of GameObjects. I move all these GameObjects to a certain position along the Z axis. This works perfectly, but this is where I get stuck.
I want the GameObjects in that array to return to their original Z positions. I was thinking of using another Array to store the Number/Float of the Z position. But I don't have a clue how to do this. I'm using JavaScript.
Answer by flamy · May 24, 2012 at 10:45 AM
var temp:GameObject[] = GameObject.FindGameObjectsWithTag("so and so tag");
var originalZ:int[];
originalZ=new int[temp.Length];
for(var i=0;i<temp.Length;i++)
{
originalZ[i]=temp[i].transform.position.z;
}
Your answer
Follow this Question
Related Questions
Storing transforms from objects in Array 1 Answer
Array doesn't increase or add element 1 Answer
Question on for loop with array 0 Answers
Make object move in a direction depending on where it spawns? (C#) 1 Answer
How to set to game objects's position from 2 different game objects arrays equal to each other? 0 Answers