I'm having a problem with the center of the localScale operation. Code is like this:
transform.localScale = new Vector3(transform.localScale.x*boundsSizeVelocity, transform.localScale.y*boundsSizeVelocity, transform.localScale.z*boundsSizeVelocity);
`boundsSizeVelocity` is a float value for the ratio which I want to scale by and is constantly changing.
All this works perfectly, except the center of the scale operation is always the center of the game object. I need to scale the object from an arbitrary position.
Is the some way of telling Unity what the center of my scale operation should be?
EDIT
Right, finally got round to implementing this. It has one major problem, my child object is rotating at the same time as scaling. Attaching the Empty GameObject makes the child dependant on the parent's rotation, which is not what I want.
Parent your GameObject to a new empty GameObject. Then you can offset it relative to that empty object's position, and apply your scale values to the empty parent object.
Because your original gameobject is now a child, it's affected by the parent's scale, but the scale is applied relative to the parent's centre.
Get your transform's world position. Translate your transform to the point you want to scale from. Scale. Translate NOT back to your old world position, but to what that old world position would be after the scaling (i.e. something like TransformPoint(myOldPosition)).