# Finding the dimensions of a cube, exploiting them.

This is a bit tricky; I want to find the dimensions of a cube, take those numbers, input them into an equation one-at-a-time, and then end up with three new numbers as the result.

Let's say I have a 4x2x10 cube. I take those dimensions, and put each one through the same equation, to get three new numbers:

"Using "25/(x/2)"

``````.25/(4/2) = 0.125
.25/(2/2) = 0.25
.25/(10/2) = 0.05

``````

How can I do that?

Didn't quite understand it, but the basics will be the same no matter what you want to do with them.

If the cube started off as the basic cube that you can create in Unity - it's dimensions are 1x1x1 units on creation. When you scale it, or parent it and scale the parent - you simply alter the scale factor of its' transform. To get the correct scale you can use Transform.lossyScale. Read up on it, since it's not 100% accurate in some cases where the transform you're checking has a parent that is skewed. This will give you the global scale of the object. If you need a scale compared to it's parent - use Transform.localScale.

When you're starting out, try and start with a simple hierarchy to see how it works. No parent, then one parent and so on. Try and rotate the parent and children to see if your script still works if the objects are not exactly at the same rotation and scale.

``````Vector3 ThreeNewNumbers (Vector3 dimensions) {
for (int i = 0; i < 3; ++i) dimensions _= .5F / dimensions*;*_
_*return dimensions;*_
_*}*_
_*```*_``````