Hello everyone, I’m making a crafting recipe dictionary. I am using viewport frames to show the object. However, they are all offcenter:
and very small. Is there a way I can modify my script to make it centered, and bigger, so the player can see it?
for count = 1, length(imageID) do
local ImageButton = Instance.new("ViewportFrame")
ImageButton.Parent = frame
ImageButton.Name = "Slot"..count
--ImageButton.Image = imageIDTable[count]
ImageButton.LayoutOrder = count
local clone = game.ReplicatedStorage[CraftableList[count]]:Clone()
clone.Parent = ImageButton
end
starmaq
(starmaq)
#2
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))
1 Like