How does scale work in nested game objects?

I’m a bit confused about the scale in this engine. As I’ve understood it, a scale of 1 is equal to 1 meter.

If I create a box of the size 1x1x1 and now create a cube inside this box, the cube states that it is also in the scale of 1x1x1, clearly - this is not equivalent to meters anymore, as it’s a child of the box - and the box is larger.

Of the looks of it, the cube’s scale is now relative to 1 cm. However, if I import a 3D asset and put it in the same box, the object appears much larger than the previous cube even if they both show a scale of 1.

I want to get the scale right, because I need the gravity and applied forces to work properly - but I’m a bit lost here of how the scale actually works. Maybe anyone can shed some light on to this for me?

You seem to confuse scale and size. They are two completely different ideas. The size of an object is measured in units. One unit in Unity is usually one meter, however that’s just convention with the physics system. In any other sense it’s just “one unit”.

The scale of an object is a unitless factor. By default an object usually has a scale of 1 in all axes. That means if an object has a size of 4.5 units in the x axis and has a scale of 1, the object will have an actual size in the world of 4.5 units. If you set the scale of that object to 2, it would have a size of 9.

Note that every gameobject creates its own coordinate system. This is where child objects “live” in. That coordinate system scales with the object. So is your object has a scale of 2, a step of 1 unit inside that coordinate space would actually move 2 units in world space.

When you import a model no one knows what internal unit has been used. In the end it’s just numbers. A modelling application might store the actual real world unit size inside some meta data. But in the end it doesn’t really matter. Unity allows to set a scale factor when you import a model. This allows you to scale the actual mesh data by some conversion factor. It’s always better when the gameobjects themselfs have a uniform scale of 1.

I don’t really get your example. If you have a gameobject with a uniform scale of 1 (so 1 on each axis) the size of a child object won’t change at all. So if you have a cube gameobject with scale of (1,1,1) and you add another cube gameobject as child which also has a scale of (1,1,1), the two cubes will have the exact same size. The default cube mesh in Unity has vertex coordinates that goes from -0.5 up to 0.5 which gives the object a “local” size of 1. Of course as already said when you scale the cube, you scale it’s local space with it. So if the outer cube has a scale of (2,2,2) it’s twice as big as it was before. The child cube which still has a scale of (1,1,1) would still have the same size as the parent cube since the coordinate system it lives in has been scaled up by a factor of 2.

Watch out: When you parent / unparent object in the hierarchy or by using transform.parent from code, Unity will actually try to adjust the scale of the child so the world space size stays the same. This is not possible in all cases but in most cases this works just fine. For example imagine two default cubes in the scene. We call one parent, the other child but for the time being they just sit next to each other and the child cube is not a child yet. Now when we scale up the parent to 2 it will be twice as big as the child since they are independent at the moment. Now when we drag the child onto the parent to actually make it a child, Unity will adjust the scale of the child so it keeps it’s original size. That means the child’s scale would be set to (0.5, 0.5, 0.5). As the child cube is now an actual child of the parent cube it automatically inherits the scale from the parent. Since it’s scaled down by a factor of 0.5 it’s still just one unit in size. However inside the coordinate system of the parent cube, the child cube only has a size of 0.5.

Please note that Unity does nothing special here. That’s how pretty much any gameengine works. This is just ordinary linear algebra. If you have issues with vectors, scaling, coordinate systems, etc I would recommend you watch the brilliant essence of linear algebra series of 3b1b. I’d like to add that even I learned most of that stuff over a decade ago, I’ve watched some of the videos already several times. It just helps to refine your understanding of things that might be considered trivial by some people. Especially when in comes to matrices in higher dimensions. There are so many different ways how you can interpret them.

Thank you @Bunny83 for your detailed explanation, and thanks for the video series tip! I guess what I’m really confused about then is where these units are hiding. Is there a way to see these units in the editor?

I’ll try and clearify my confusion from above;

Lets say I create a cube with (1.5, 1.5, 1.5) scale, and now move this inte an empty GameObject of (1.0, 1.0, 1.0). The GameObject’s bounding box grows to the size of the cube, but is represented as a scale of 1.0.
If I inspect the cube, I can see the scale is 1.5 but the size is the same. This is what confused me.

From the perspective of the cube, it is clear that it is 1.5 times 1 meter. But when I look at the GameObject it is not that apparent (as I just see the scale and no units of how big the encompassing bounding box really is).