- Home /
Question by
karinsk · May 24, 2014 at 09:48 PM ·
c#instantiatearrayy height
C# How to Find the Height of an Instantiated GameObject in an Array?
I wrote code to instantiate a random GameObject on a side of the game screen...How can I return the height of the GameObjects in the array in order to stack one GameObject on top of the other?
Instantiate((rocksArray[RandomNumbGenerator()]),new Vector3(Screen.width,0,0), Quaternion.identity);
Thanks!
Comment
Best Answer
Answer by robertbu · May 24, 2014 at 09:49 PM
GameObject go = Instantiate((rocksArray[RandomNumbGenerator()]),new Vector3(Screen.width,0,0), Quaternion.identity) as GameObject;
Then you can get the access to go.transform.position.
Thanks! I was missing "as GameObject" when I tried to do that before.
$$anonymous$$uch appreciated.