Simple Maths Q: Scaling child objects

Hi guys,

I want to scale objects up and down, and know by what percentage from their original size I am scaling them by. They are children objects, with more than one layer of parent. It’s actually parent.parent.parent.gameObjectToScale. I wanted to know the maths behind scaling an object, which is already parented to objects which are scaled to different extents. I’d like to know the maths to calculate the world scale of that object.

These particular objects are Sprites, so I was thinking it’d be something along the lines ofchildObj.localScale = childObj.localScale * ((parentBounds * parentTransform.localScale) * (anotherParentBounds * anotherparentTransform.localScale) * (yetAnotherParentBounds * yetanotherparentTransform.localScale));

I know this exact calculation is totally wrong, but does someone know the correct way to do this?

Thanks!

Found the answer myself. For anyone wondering…

You multiply the scaler’s between each other, and multiply the object by that final scale. Here is my example code for it:

float dist = Vector3.Distance(marker.transform.position, hit.point);
                    float scale = line.transform.parent.parent.transform.localScale.y * line.transform.localScale.y;
                    dist = dist / scale;
                    targetAnchor.transform.localPosition = new Vector3(0, (dist) , 0);