I am using localScale.y to scale a cube but I would like the scaling to make the cube “taller” rather than the current way which ends up with half of it through the floor This is most easily explained with a picture. (1) is the original cube. (2) is what I want. (3) is what I get.
Now I do understand why this happens. The cube is scaled from the center point in both directions equally.
My app is a music visualisation program so the scaling happens a few times per second so I don’t think it is poissible to keep on correcting the y position of the cube else the cube will be out of place when the cube gets smaller.
Is there a nice way to change how the cube is scaled or a workaround for this?
Actually, yes, you can change the y position, it updates very quickly, should be just fine. But if that is really not what you want to do for some reason, a) model the cube with Blender or other 3d program, where the origin is at the bottom, or b) put the cube into an empty gameobject, offsetting it upward .5, so the new gameobject, when at 0,0,0, has a cube in it that sits ‘on the ground’, then scale that containing object instead.
Hello.
The above mentioned technique is also a solution but if you have any designer or any know how to use 3ds Max or Maya you can set the pivot point of that object to the bottom which you mentioned earlier (Cube), and just scale it upwards then see it will only scale in the upward direction and the bottom positioning will remain un-effected.
Set Pivot point to the bottom of the cube or opposite to the side in which you want to scale which is bottom.