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

Rolling a camera and haveing it follow?

Asked by 7 years ago
Edited 7 years ago

Hi, am trying to figure out how I can roll a camera and have it follow the player/part. I've found that I can roll the camera using

workspace.CurrentCamera:SetRoll(math.rad(20))

in a local script inside "StarterPlayerScripts", and changing the CameraType to "Scriptable". Unfortunately when I set it to "Scriptable" the camera dos not follow. When I set it to "Follow" the camera will follow the Player but will not roll. Isn't there some way to make the camera roll and follow? I thought I saw some check box for VR stuff that might allow the cameraTypes to be able to roll?

Update: Here is some code I just got some where else and added Interpolation. Works pretty well actually but still not perfect. Have any suggestions to make it smoother?

repeat wait() until game.Players.LocalPlayer

local target = game.Players.LocalPlayer.Character.Head
local camera = game.Workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
print(camera.CameraType) -- Debug to make sure that I don't get "Camera isn't set to scriptable" errors


function Update() -- Track player
    while true do 

        workspace.CurrentCamera:Interpolate(CFrame.new(workspace.CurrentCamera.CFrame.X,workspace.CurrentCamera.CFrame.Y,workspace.CurrentCamera.CFrame.Z),
                                CFrame.new(target.Position),
                                --* CFrame.new(0, 5, 10)
                                --* CFrame.Angles(-0.5, 0, 0),0,0.1),
                                0.1)
       camera.CoordinateFrame = CFrame.new(target.Position)
                                * CFrame.new(0, 5, 10)
                                * CFrame.Angles(-0.5, 0, 0)
        wait(0.1)
    end
end

spawn(Update)


function FlipCamera(flip)
    local e = "A value in FlipCamera returned nil"
    if flip == nil then error(e) end
    local value = nil
    if flip == true then
        print("Flipping camera")
        value = 0
        camera:SetRoll(value)
        while camera:GetRoll(math.rad) <= math.pi do
            print("flip")
            camera:SetRoll(math.rad(value))
            value = value + 10
            print(camera:GetRoll(math.rad))
            wait()
        end 
        camera:SetRoll(math.rad(180))
    elseif flip == false then
        print("Flipping camera back")
        value = math.pi
        camera:SetRoll(value) 
        while camera:GetRoll(math.rad) >= 0 do
            print(camera:GetRoll(math.rad))
            camera:SetRoll(camera:GetRoll(math.rad) - 0.2)
            wait()
        end
        camera:SetRoll(0)
    end
end

wait(4)
FlipCamera(true)
wait(4)
FlipCamera(false)
-- Flip the camera by calling the function FlipCamera(), arguments true = flip the camera upside down, false = flip the camera right side up

0
http://wiki.roblox.com/index.php?title=API:Class/Camera/Interpolate You could interpolate the camera behind the player every second or so with a loop, meanwhile changing the roll as you please. saenae 318 — 7y
0
I actully just did that right before you commented this XD Worthy0ne 68 — 7y
0
My work is above if you have any suggestions ;) Worthy0ne 68 — 7y

Answer this question