How to get GameElements (RigidBody) size in Unity
Posted
by
Shivan Dragon
on Game Development
See other posts from Game Development
or by Shivan Dragon
Published on 2012-09-06T18:24:57Z
Indexed on
2012/09/06
21:53 UTC
Read the original article
Hit count: 409
I've made a prefab consisting of a Cube which I've first scaled to more resemble a brick. There's also a Rigidbody added to the cube (in the prefab). Now I want to use that prefab in a c# script to make a wall out of multiple bricks.
My question is, how can I access the dimensions of my brick (width, height, the z dimension size) so that in my script I can make bricks which are placed one next to the other (and then one on top of the other)?
I've looked at the documentation for GameObject and Rigidbody but I can't find anything helpful.
Just for refference, my script so far is:
public GameObject brick;
void Start () {
Instantiate(this.brick, new Vector3(0.01326297f, -30.07855f, 100f), Quaternion.identity);
// int brickWidth = this.brick.????;
}
© Game Development or respective owner