Hello, I’m making a racing game and usign viewport frames to display the models. I am having some issues however with correctly positioning the cars, and I find it extremely difficult and tedious to do it manually. I was wondering if there was a plugin or “auto display code” or module I could use. This is my current code:
local module = {}
local bips = {
Vector3.new(-1,-1,-1),
Vector3.new(-1,-1, 1),
Vector3.new(-1, 1,-1),
Vector3.new(-1, 1, 1),
Vector3.new( 1,-1,-1),
Vector3.new( 1,-1, 1),
Vector3.new( 1, 1,-1),
Vector3.new( 1, 1, 1),
}
function module.GenerateBuildingThumbnail(model, vp)
local cam = Instance.new("Camera", vp.Parent)
local building = model:Clone()
local cf, size = model:GetBoundingBox()
local buildingCF = building:GetPivot()
local buildingPos = buildingCF.Position
local boundingBoxOffset = buildingPos - cf.Position
local viewDistance = size.Magnitude * 0.3
vp.LightDirection = -Vector3.yAxis
vp.LightColor = Color3.fromRGB(255, 255, 255)
vp.CurrentCamera = cam
building.Parent = vp
buildingCF = buildingCF - buildingPos + boundingBoxOffset
cam.CFrame = CFrame.lookAt(Vector3.one * viewDistance, Vector3.zero, Vector3.yAxis)
building:PivotTo(buildingCF * CFrame.Angles(0, math.rad(270), 0))
end
return module
and this is what it results in
So as you can see while its close, its not exact.