- Home /
is it possible to scale from one side (not axe) ?
Hello everyone,
when you try to scale an object along the X-axe, it will get bigger from left and the right, is there a way to avoid that ? Why ? am trying to find the easiest way to draw a line (click and drag) and i believe that using a Quad, rotate it toward the mouse and scale it forward is the easiest way to do it, but am facing the dual-side scaling issue, is there a way to fix that ?
thank you and have a great day
I think it all depends on the pivot of the object. If the pivot is in the center it will scale from both sides.
Answer by GameVortex · Feb 04, 2014 at 08:27 AM
A usual way of doing this is to move it related to how much it is scaled, so it appears it is only scaling on one axis. But another easy way is to child the object you want to scale to an empty GameObject, offset the quad so the root of the parent is on the side of the quad, and then apply the scale to the parent object instead.
i already thought about the moving solution but i didn't really like it, but the parent-child approach seems to be the right call, thank you ^^
If you're drawing a line, there is the possibility of using a LineRenderer. No scaling issues this way.
For what it's worth, both methods -- "hand-move during scale" and "child so pivot is at one edge" -- work out to exactly the same math. When you scale an object with children, it scales the child's local coords and moves the child that much. The only difference is that Unity does the movement math for you.