Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Why does this Camera pan eventually slow down and stop?

Asked by
alibix123 175
10 years ago
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?

0
What exactly are you trying to do? User#2 0 — 10y
0
I'm trying to pan the camera around in a circle, slowly. alibix123 175 — 10y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

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
Ad

Answer this question