- Home /
How to get position of multiple platforms?
Hello,
I am creating platforms randomly, using this tutorial
http://catlikecoding.com/unity/tutorials/runner/
In one frame, 6 platforms are created randomly. Now I need to access the position and size of each platform. How can I do that?
Answer by SepM · Jul 10, 2014 at 12:41 AM
To get the position, you can assign a variable to each one.
 var platformLocation:Vector3;
This records the position and you can use it later on. Now, recording the size, you'll have to get each axis (x,y,z) separately. Use
 var width = collider.bounds.size.x;
 var length = collider.bounds.size.y;
 var thickness = collider.bounds.size.z;
So after a little testing, I came up with this:
 var width : int;
 var height : int;
 var thickness : int;
 var platformLocation:Vector3;
 
 function Update(){
         width = collider.bounds.size.x;
         length = collider.bounds.size.y;
         thickness = collider.bounds.size.z;
 
         platformLocation = gameObject.transform.position;
 }
I hope this answers your question completely.
Thanks but they are all created in a queue using a loop. How can i assign each to a variable? Sorry for being too stupid :/
An array or list would be a perfect way to store each variable as they are created.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                