im trying to position eggs Infront of a camera so they all fit and scale to fit the screen size and arrange themselves like in pet sim 99
heres what i have so far
local camera = workspace.CurrentCamera
local Eggs = SpawnEggs()
local eggMinOffset = 0.3
local function UpdateEggPositions(EGGS)
local height = math.tan(math.rad(camera.FieldOfView/2)) * 2 * (eggMinOffset)
local width = height * camera.ViewportSize.X / camera.ViewportSize.Y
local rows = math.round(math.ceil(math.log(#Eggs)))
local RowEggsAmount = math.round(#Eggs / rows)
for i = 1,rows do
for i = 1,RowEggsAmount do
local Egg = EggModel:Clone()
Egg:ScaleTo(0.05)
end
end
--Old
for i,v in Eggs do
v:ScaleTo(0.05)
local spacing = width / #Eggs
local offsetindex = i - (#Eggs + 1) / 2
local offsetPosX = offsetindex * (spacing)
local Forward = camera.CFrame.LookVector
local right = camera.CFrame.RightVector
local TargetPos = camera.CFrame.Position
+ Forward * (v.PrimaryPart.Size.Z + eggMinOffset)
+ right * offsetPosX
local FinalCFrame = CFrame.new(TargetPos,TargetPos + camera.CFrame.LookVector)
v:SetPrimaryPartCFrame(FinalCFrame)
end
end