Hello,
I am creating platforms randomly, using this tutorial
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?
Hello,
I am creating platforms randomly, using this tutorial
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?
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.