Make union fit in viewport frame

Hello everyone, I am making a crafting recipe dictionary, that has 20+ viewport frames. Is there an easy way to always make the union in each of the viewport frames fit perfectly? I really don’t want to have to guess & check every single frame. Thank you!

I’d recommend using this

It contains two methods you can check out. GetFitDistance will return a distance to offset the camera by from the model’s position

local viewportFit = ViewportFit.new(ViewportFrame, currentCamera)

viewportFit:SetModel(model)

currentCamera.CFrame = model:GetPivot() * CFrame.new(0, 0, viewportFit:GetFitDistance(model:GetPivot().Position))

Set the union’s ‘CFrame’ using the following expression.

Union.CFrame = CFrame.new(0, 0, -math.max(Union.Size.X, Union.Size.Y, Union.Size.Z)) * CFrame.Angles(0, math.pi, 0)
1 Like