Heyo I have this code for my camera and need some help because I’m not sure how I could zoom in on something.
local Distance = 12
local Xoffset = 0
local Yoffset = 2
local Zoffset = 10
local function CalculateAveragePosition()
local Total = Vector3.new()
for _,HRP in pairs(HRPS) do
Total += HRP.Position
end
return Total / #HRPS
end
--local function CalculateAverageMagnitude()
-- local Total = 0
-- for _,HRP in pairs(HRPS) do
-- Total += (HRP.Position - StageCam.Position).Magnitude
-- end
-- return Total/#HRPS
--end
for _,HRP in pairs(workspace.Game.Characters:GetDescendants()) do
if HRP.Name == "HumanoidRootPart" then
table.insert(HRPS,HRP)
end
end
--> This code is in a render stepped
local AveragePos = CalculateAveragePosition()
--local AverageMag = CalculateAverageMagnitude() + Zoffset
StageCam.Position = AveragePos
WorkspaceCam.CFrame = StageCam.CFrame * CFrame.new(Vector3.new(Xoffset,Yoffset,Distance))
Heres a video of how it currently looks
And so what I wanna do is when a player does a certain attack I wanna slightly zoom in on them