How to get GameElements (RigidBody) size in Unity
- by Shivan Dragon
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.????;
}