I was wondering if it is possible to have a GameObject scale to the size of a smaller object. I have 48 planets for my game and they’re all different sizes but when brought into the scene they need to be made the same. Any suggestions?
Yes, you can use Bounds.size. Using C#, you can retrieve the size of an object like this:
Vector3 sizeCalculated = GetComponent<Renderer>().bounds.size;
Then, scale the “new” object this way:
transform.localScale = sizeCalculated;
Hope this could be a good starting point.
If your planets are the same gameObject, setting the scale of each planet to the same value will do it. Otherwise, you could use the mesh of your planet’s bounds to know the min/max point and compute the factor you should apply to the size to normalize them.