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
1 | 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?
01 | repeat wait() until game.Players.LocalPlayer |
03 | local target = game.Players.LocalPlayer.Character.Head |
04 | local camera = game.Workspace.CurrentCamera |
05 | camera.CameraType = Enum.CameraType.Scriptable |
06 | print (camera.CameraType) |
12 | workspace.CurrentCamera:Interpolate(CFrame.new(workspace.CurrentCamera.CFrame.X,workspace.CurrentCamera.CFrame.Y,workspace.CurrentCamera.CFrame.Z), |
13 | CFrame.new(target.Position), |
17 | camera.CoordinateFrame = CFrame.new(target.Position) |
18 | * CFrame.new( 0 , 5 , 10 ) |
19 | * CFrame.Angles(- 0.5 , 0 , 0 ) |
27 | function FlipCamera(flip) |
28 | local e = "A value in FlipCamera returned nil" |
29 | if flip = = nil then error (e) end |
32 | print ( "Flipping camera" ) |
35 | while camera:GetRoll(math.rad) < = math.pi do |
37 | camera:SetRoll(math.rad(value)) |
39 | print (camera:GetRoll(math.rad)) |
42 | camera:SetRoll(math.rad( 180 )) |
43 | elseif flip = = false then |
44 | print ( "Flipping camera back" ) |
47 | while camera:GetRoll(math.rad) > = 0 do |
48 | print (camera:GetRoll(math.rad)) |
49 | camera:SetRoll(camera:GetRoll(math.rad) - 0.2 ) |