Currently making a game with fixed camera angles and was wondering how do i make them work, do i make it activate when it hits a specific area or a specific block that changes the camera?
__________________________________________________________________________
Watch my video to see the result of the code!
Local Script inside StarterPlayerScript
-- Declaration Section --//Game Services local Workspace = game:GetService("Workspace") local Camera = Workspace.CurrentCamera local Lighting = game:GetService("Lighting") local Player = game:GetService("Players").LocalPlayer --// Folder local CameraFolder = Workspace:WaitForChild("CameraFolder") local TouchedFolder = Workspace:WaitForChild("TouchedFolder") --//Lighting ColorCorrecting local ColorCorrection = Lighting:WaitForChild("ColorCorrection") --//List of Part Cameras local Camera1 = CameraFolder:WaitForChild("Camera1") --These are all parts local Camera2 = CameraFolder:WaitForChild("Camera2") local Camera3 = CameraFolder:WaitForChild("Camera3") local Camera4 = CameraFolder:WaitForChild("Camera4") local Camera5 = CameraFolder:WaitForChild("Camera5") --//List of Touched Parts local Touched1 = TouchedFolder:WaitForChild("Touch1") --These are all parts too local Touched2 = TouchedFolder:WaitForChild("Touch2") local Touched3 = TouchedFolder:WaitForChild("Touch3") local Touched4 = TouchedFolder:WaitForChild("Touch4") -- Processing Section --Initializing Scriptable Camera repeat wait() Camera.CameraType = Enum.CameraType.Scriptable until Camera.CameraType == Enum.CameraType.Scriptable Camera.CFrame = Camera1.CFrame --First Touch local function touch1 () Touched1:Destroy() for number = 0, 1, 0.1 do Camera.CFrame = Camera1.CFrame:lerp(Camera2.CFrame, number) wait() end end --Second Touch local function touch2 () Touched2:Destroy() for number = 0, 1, 0.01 do ColorCorrection.Brightness = number wait() end local TeleportPosition = Vector3.new(-30, 5, -65) Player.Character:MoveTo(TeleportPosition) wait(2) repeat wait () Camera.CFrame = Camera3.CFrame until Camera.CFrame == Camera3.CFrame for number = 1, 0, -0.01 do ColorCorrection.Brightness = number wait() end end --Third Touch local function touch3 () Touched3:Destroy() for number = 0, 1, 0.01 do ColorCorrection.Brightness = number wait() end repeat wait() Camera.CFrame = Camera4.CFrame until Camera.CFrame == Camera4.CFrame wait(1) for number = 1, 0, -0.01 do ColorCorrection.Brightness = number wait() end end --Fourth Touch local function touch4 () Touched4:Destroy() for number = 0, 1, 0.1 do Camera.CFrame = Camera4.CFrame:lerp(Camera5.CFrame, number) wait() end end -- Connecting Section Touched1.Touched:Connect(touch1) Touched2.Touched:Connect(touch2) Touched3.Touched:Connect(touch3) Touched4.Touched:Connect(touch4)
lerp
-ing (Linear Interpolation)is a function
that moves from one part to the another part. It's increment can be totally decided by the user by creating a for loop. Since we want these effects to work when the Player
reaches certain position, I used Touched
to connect it. Touched
is also a function which when a LocalPlayer
touches the part, the work occurs.
Now some could argue that this code would look inefficient. And I can understand why. Some people would say that you can basically create One Whole Function and just move up the values. Now that would only be possible if all those functions were doing the same thing.
I do realize that this is not exactly what you may have wanted. And that is perfectly my goal. ScriptingHelpers goal is to guide you through your problems, not solve your problem. This code will help you understand how to manipulate Camera so that in future, you wouldn't have to ask us here or take time to digest all the informations. Remember to be creative!
Hope you learnt something from this tutorial
Well I'm not totally sure what you're aksing. If you could revise your question that would be great! There is a whole wiki on this, however : http://wiki.roblox.com/index.php/Camera_manipulation
You can simply use the LOCAL script,
local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 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 + math.rad(1) end
A fixed camera type means its stationary, however. I'll attempt to fix my code if you have any more issues, or if I didn't understand your question.