Hi, so I have a little question about meshes.. as the title suggests I would like to know how the 'Scale' of the mesh is relative to the mesh's 'Offset'.
Basically, I'm attempting to create a slider Gui that controls the window of a car, so to do this I used mesh scale and offset (due to meshes scaling from the center), the problem is, I'm not sure how to calculate the offset so the window will scale down, but keep the bottom in the same place.
I hope that was understandable.
Thanks, -Nen
The offset of a mesh is in measured in studs and the scale is measured in a percent multiplier of the actual size of the mesh. You want to offset the window by half as much as it scales down by, so you'll have to get these two things to the same units of measurements.
In order to do that, we will have to calculate the actual size of the mesh [i.e. the size the mesh is when it is scaled at 100% in all directions (scale = Vector3.new(1, 1, 1))]. The easiest way to do this right now is to copy the MeshId into a MeshPart and record the size of that part. This will be the size of the bounding box of the mesh.
In the case where the mesh doesn't have a MeshId or the edge of the mesh you want to 'stay still' doesn't extend up to the bounding box, you will have to figure out the size in a different way. What you will want to do is create a part and make the outside edges of the part line up (as close as you possibly can) with the edge you want it to resize from. Record the size of that part.
Now that we have the size of the part at 100% scale, we can calculate the offset we need to make the part to appear to scale from one direction instead of the origin.
Example: Shrink mesh down from the top face by half of original size
local size -- Size of the mesh at 100% scale you found earlier local mesh -- Object hierarchy of the mesh to resize local function scaleMesh(scale) mesh.Scale = scale mesh.Offset = (size*scale - size)/2 end scaleMesh(Vector3.new(1, 0.5, 1))
Note that this will likely take some adjustments to get working correctly, but it is the only way I am aware of.