Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this Camera pan eventually slow down and stop?

local target = workspace.sub --this is a part
local camera = workspace.CurrentCamera
camera.CameraSubject = target
local angle = 0


while true and wait() do

    	camera.CoordinateFrame = CFrame.new(target.Position)  --Start at the position of the part
                           
	camera.Focus = camera.Focus * CFrame.new(1,0,0)

end

It works for a few seconds then slows down and slightly pans downwards, what did I do wrong?

2 comments

0

What exactly are you trying to do?

0

I'm trying to pan the camera around in a circle, slowly.

1 answer

✓ Accepted answer

I don't understand matrix math, especially with CFrame, so I prefer to do camera manipulation manually:

local target = Workspace.sub
local camera = Workspace.CurrentCamera
camera.CameraSubject = target
local angle = 0 --Starting anle, in degrees.

local foc = Vector3.new(0, -.1, 0) --Only x and z are affected by the rotation math. You can change y freely.
while wait() do
	foc = Vector3.new(math.cos(math.rad(angle)), foc.Y, math.sin(math.rad(angle)))
	camera.CoordinateFrame = CFrame.new(target.Position)
	camera.Focus = CFrame.new(target.Position + foc)
	angle = angle + .5
end

This discussion is preserved as it was. New answers, comments, and votes are closed.