Home > Back-end >  Compare tow Vector3 localScale then add it to another GameObject
Compare tow Vector3 localScale then add it to another GameObject

Time:10-31

i want to calculate two localScale value's Proportion

the normal one and the enlarge one.

Then make another GameObject multiply this Proportion

like this

var localscaleA = GameObjectA.transform.localscale.


var Proportion = GameObjectA.transform.localScale/ GameObjectAenlarge.transform.localScale; 

GameObjectB.transform.localScale = GameObjectB.transform.localScale * Proportion ;

CodePudding user response:

You will need to do this component wise e.g.

var localscaleA = GameObjectA.transform.localscale;
var localscaleAEnlarge = GameObjectAenlarge.transform.localScale;
var Proportion = new Vector3(localscaleAEnlarge.x / localScaleA.x, localscaleAEnlarge.y / localScaleA.y, localscaleAEnlarge.z / localScaleA.z);
GameObjectB.transform.localScale = Vector3.Scale(GameObjectB.transform.localScale, Proportion);
  • Related