Hey forums, I’m trying to make Billboard GUI’S that contain a Viewport Frame. The Viewport Frame is supposed to render a model within the Billboard and have it fill the Billboard GUI. The GUI has to be unique for many different models so it has to be automatic using some sort of math that i don’t understand.
I attempted to use ViewportFrame Model Fitter by @EgoMoose Link This doesn’t work for Billboard GUI’s and I’m lost. I know that its not a coding error because I copy and pasted the code in a ScreenGUI and in a BillboardGUI and the Billboard screwed up, any ideas?
Code for ScreenGUI
local ViewportFit = require(game.ReplicatedStorage.ViewportFit)
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()
local viewport = player.PlayerGui.ScreenGui.ViewportFrame
local camera = Instance.new("Camera", viewport)
local model = game.Workspace.Model:Clone()
viewport.CurrentCamera = camera
model.Parent = viewport
local vpfModel = ViewportFit.new(viewport, camera)
vpfModel:SetModel(model)
camera.CFrame = vpfModel:GetMinimumFitCFrame(CFrame.fromEulerAnglesYXZ(0,0,0))
Code for BillboardGUI (There is some code above but this is the base code for camera positioning.)
local viewport_fit = require(game.ReplicatedStorage.Performance.ViewportFit)
local viewport = Instance.new("ViewportFrame", billboard)
local view_cam : Camera = Instance.new("Camera", viewport)
local viewport_model = model:Clone()
local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
player.CharacterAdded:Wait()
local orientation = CFrame.fromEulerAnglesXYZ(0,0,0)
local vpfModel = viewport_fit.new(viewport, view_cam)
vpfModel:SetModel(viewport_model)
view_cam.CFrame = vpfModel:GetMinimumFitCFrame(orientation)
There are no error printed to the console just two drastically different results.
Billboard Screenshot
As you can see the part is not filling the whole billboard and is also angled very incorrectly. The Viewport frame is scaled correctly at {1, 0}, {1, 0} making it fit to the billboard.
ScreenGUI Screenshot
And in the ScreenGUI you can see that the test part fits perfectly in the ScreenGUI with the same code.
Any help on this would be greatly appreciated.