What is the new replacement for PanUnits

It says pan units is patched
https://developer.roblox.com/en-us/api-reference/function/Camera/PanUnits
What is the new replacement for it?

1 PanUnit is 45 degrees or pi/4

I never asked uh what are pan units, I am asking it says pan units is depcreated, dont use it for new work

i mean u can just use the camera focus?

Uh whats that?

After a bit of testing, I’ve managed to get a very rough “pan” effect working with the following code

local RunService = game:GetService("RunService")

local Camera = workspace.CurrentCamera

task.wait()

Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(0, 5, -3)

local Target = workspace.SpawnLocation.Position

RunService.RenderStepped:Connect(function(Delta)
	local Direction = (Camera.CFrame.Position - Target)
	
	local AtPosition = (CFrame.new(Target) * CFrame.Angles(0, math.rad(1), 0) * CFrame.new(Direction)).Position
	
	Camera.CFrame = CFrame.lookAt(AtPosition, Target)
end)

Replace Target with the position of the thing you want to pan around, and CFrame.new(0, 5, -3) with the starting point of the pan.

1 Like

I’ve made it into a functions which works even with normal camera.

local function PanCamera(units : number)
	local Camera = workspace.CurrentCamera
	local Pos = Camera.CFrame.Position 
	local CF = CFrame.new(Pos)
	local Dir = (CFrame.lookAt(Vector3.new(0,Pos.Y,0),Vector3.new(0,Pos.Y,0) + CF.LookVector + CF.RightVector))
	local X,Y,Z = Dir:ToOrientation()
	
	Camera.CFrame *= CFrame.Angles(0,units * Y,0)
end
1 Like