01 | local target = workspace.sub --this is a part |
02 | local camera = workspace.CurrentCamera |
03 | camera.CameraSubject = target |
04 | local angle = 0 |
05 |
06 |
07 | while true and wait() do |
08 |
09 | camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part |
10 |
11 | camera.Focus = camera.Focus * CFrame.new( 1 , 0 , 0 ) |
12 |
13 | end |
It works for a few seconds then slows down and slightly pans downwards, what did I do wrong?
I don't understand matrix math, especially with CFrame, so I prefer to do camera manipulation manually:
01 | local target = Workspace.sub |
02 | local camera = Workspace.CurrentCamera |
03 | camera.CameraSubject = target |
04 | local angle = 0 --Starting anle, in degrees. |
05 |
06 | local foc = Vector 3. new( 0 , -. 1 , 0 ) --Only x and z are affected by the rotation math. You can change y freely. |
07 | while wait() do |
08 | foc = Vector 3. new(math.cos(math.rad(angle)), foc.Y, math.sin(math.rad(angle))) |
09 | camera.CoordinateFrame = CFrame.new(target.Position) |
10 | camera.Focus = CFrame.new(target.Position + foc) |
11 | angle = angle + . 5 |
12 | end |