Rotate your object so that the scaling direction is on the z-axis.
Scale your object.
Rotate your object back.
Additional info
To scale an object in some way, doesn’t matter what way: First put it on the origin before scaling.
In the viewing pipeline the following aspect is very important: Scale -> Rotate -> Translate. This is how it goes by default. If you want to scale it in some strange way, rotate your object to the right position (or translate even). After that, you can scale it. Then, return it to your original position.
For your case
Your object is in the middle, which will scale in the z-axis symmetrically. So: Translate your object to one side of the xy-plane.
Update
void Update()
{
Vector3 oldP = MyObject.transform.position;
Quaternion oldR = MyObject.transform.rotation;
// set the object to the origin
MyObject.transform.position = new Vector3(0,0,halfYourObjectsThickness);
MyObject.transform.rotation = Quaternion.identity;
// scale your object, forgot how to do that
// Your ScaleMatrix will contain a scale in the Z direction.
MyObject.transform = ScaleMatrix * MyObject.transform;
// set your object back to where it came from.
MyObject.transform.position = oldP;
MyObject.transform.rotation = oldR;
}
And even a picture for further understanding, where the right axis is the Z-axis:
And try googling for this: `3d transformations`
There are a lot of fun things to do with matrices, which are not just localScale. If you have questions: Ask, and don’t say: it doesn’t work. Try to understand it, then implement it.
@Dawg: Yes of course, it will only move. But you can not simply scale your object, because you want a special scale. Translate your object to one side, scale it, and translate it back in one frame. I'll update my answer.
@Dawg: Yes of course, it will only move. But you can not simply scale your object, because you want a special scale. Translate your object to one side, scale it, and translate it back in one frame. I'll update my answer.
– Marnix@Dawg: Did this help you, or do you still have some questions? If the question is ok, please press the accept button next to the answer.
– Marnix