- Home /
Scale child object to a specific size
Hi! I want to scale a dimension of a child object to a specific size. The trick is, that it's parent is scaled (non-uniformly) and rotated.
How to do this in unity? My initial assumption was, that the scale of an object equals the parent's lossyScale multiplied by the child's localScale. This clearly doesn't hold, since the parent is rotated.
Also if someone could explain how is the actual scale of the child object is calculated, I would greatly appreciate it.
So here is what i would like to do:
float targetlength; //a given target Y length
Vector3 newLocalScale;
// magic to calculate new local scale
this.transform.localScale = newLocalScale;
Comment