To keep it brief, I just have one question, what steps would I need to take to create a camera rail system that functions like this video?
My immediate thought would be to just use parts to define the trail that the camera takes, and maybe to use more parts to trigger the transition between camera types… I don’t really know how that would work though so if anyone has any better ideas I’m all ears (or eyes, I guess I should say)
The goal rotation at each frame is pointed at the character, so it would be
local goalRotation = CFrame.LookAt(cameraPosition, characterPosition).Rotation
And then you would slide the camera along a line (the rail) when the character goes outside of the bounds. Generally I think this would be like checking if the character is outside of the region defined by two lines, paralell to the camera, that are positioned at two equidistant points from the camera along a perpendicular line to where the camera looks
But if you only need to do this on the X or Z axis then you can just check the magnitude of the X and Z distance
--example for x
local OUTSIDE_OF_BOUNDS_RANGE = 10 -- can be anything
-- if the character goes out of bounds, then the camera should slide along the rail
local cameraShouldSlide = math.abs(cameraPosition.X - characterPosition.X) > OUTSIDE_OF_BOUNDS_RANGE
After you get the correct goal rotation, you would do a smooth lerp to actually move the camera
And just lots of tweaking to determine what looks the best
heres a localscript of how you would implement this in roblox studio
local RunService = game:GetService("RunService") -- Returns a service given by class name
local CurrentCamera = workspace.CurrentCamera -- reference the camera being used by the local player
CurrentCamera.CameraType = Enum.CameraType.Scriptable -- set to scriptable so players cant control camera now, only the local script can
local player = game.Players.LocalPlayer -- reference the player in the game
local character = player.Character or player.CharacterAdded:Wait() -- gets the character of the player
RunService.PreRender:Connect(function() -- fires before frame is rendered on screen
CurrentCamera.CFrame = CurrentCamera.CFrame:Lerp(CFrame.new(Vector3.new(character.PrimaryPart.Position.X, 10, 0), character.PrimaryPart.Position), 0.05) -- makes currentcamera move only on character x axis and looks at character smoothly using lerp
end)
the comments in the local script explains each line and what they do
the localscript would work correctly if its under starter character scripts
ive made a rail system ill add a download if you want to see how it works
nightmare_camera.rbxl (84.2 KB)
