- Home /
How to shorten/extend an object?
Hello, it is possible to shorten and extend an object (in my case is a simple box) but only one side of it? I don't want to scale it because it will extend on both side of the axis.. I want to do this by code. Thank you
Comment
Best Answer
Answer by demize2010 · Jun 28, 2011 at 11:27 AM
Update the position by half of your scaling ammount eg:
function scaleCube(scaleAmmount){
//Scale the object on X axis in local units
transform.localScale.x += scaleAmmount;
//Move the object on X axis in local units
transform.localPosition += scaleAmmount/2;
}
Answer by Nyo · Jun 28, 2011 at 11:51 AM
So it's a workaround, not a real "resize one side"?
Yup it's a solution to what you want to do. As far as I'm aware you can't set a new anchor point on objects other then text meshes. As this is exectued in the same frame as when its scaled there will be no visual difference. Please don't post comments as new answers.