- Home /
Question by
Armadus · Apr 20, 2014 at 11:49 PM ·
rigidbodyscaleruntimeworldspace
Can I scale an object at runtime?
I'm trying to create a "progress" bar in worldspace. I made one by instantiating multiple cubes, one top of the other, but that seems like a waste of resources. Is there any way I can create a cube and change it's Y or X scale at runtime?
Comment
Answer by SteelArrow21 · Apr 21, 2014 at 12:08 AM
You could do this:
transform.localScale = new Vector3(1, 1, 1);
transform.position += new Vector3(0.5, 0, 0);
(However long you want to wait)
transform.localScale = new Vector3(2, 1, 1);
transform.position += new Vector3(0.5, 0, 0);
...and so on
or
transform.localScale += new Vector3(1, 0, 0);
transform.position += new Vector3(0.5, 0, 0);
(However long you want to wait)
transform.localScale += new Vector3(1, 0, 0);
transform.position += new Vector3(0.5, 0, 0);
...and so on