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

Modified "Camera manipulation" script always results in the same angle?

Asked by 6 years ago

First off, a little context: I'm trying to make a fixed camera script that circles a part. For a quick start, I used the script on the Roblox wiki, which is this:

--This must be a LocalScript placed in the StarterGui

local target = workspace.BasePlate
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
--camera.Focus = CFrame.new(target.Position)
local angle = 0
local i = 0

while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position)  --Start at the position of the part
                            * CFrame.Angles(0, angle, 0) --Rotate by the angle
                            * CFrame.new(0, 200, 500)       --Move the camera backwards 5 units
    --camera.Focus = CFrame.new(target.Position)
    angle = angle + math.rad(1)

    i = i + 1
    if i > 1000 then break end
end

However, this is not what I needed, so I modified it a bit. For example, instead of targeting the Baseplate, it now targets a part I have called "CameraTarget" that is used for better control, and I added in multiplication on line 12 to gradually slow it down over time.

local target = workspace.CameraTarget
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = target
local angle = 5
local i = 0

while wait() do
    camera.CoordinateFrame = CFrame.new(target.Position)  --Start at the position of the part
                            * CFrame.Angles(0, angle, 0) --Rotate by the angle
                            * CFrame.new(0, 0, 5)       --Move the camera backwards 5 units
    angle = (angle * 0.99)

    i = i + 1
    if i > 750 then break end
    print(i)
end

However, regardless of what I change the number in "(angle * x)" to on line 12, it ALWAYS results in the same final angle, but it arrives at a different speed. I want the final rotation to be, say, 180 degrees more/less than what it currently is, but am unsure how to do that. Could anyone help me out? It'd be much appreciated.

0
CFrame.Angles needs radians. You can do some math to get the radians, or do math.rad. hiimgoodpack 2009 — 6y

Answer this question