I’m trying to make a smooth camera transition for a character swap.
The plan is to make the camera scriptable for a moment to make a transition with Tweening.
However there’s no way to know where the camera will be if I set it to Custom later on, is there a way to calculate it or move it somewhere where I want to when it’s a Custom Camera? or will I have to make a fully scripted camera to actually register the last frame when going into free camera?
Tried to research the topic through the forums but I got no success, so please any help?
Here is a script I came up with. Your best bet is to use RunService and connect to the RenderStepped event. This will run your function before the frame is rendered, and will help you avoid camera flicker. The idea is to intercept camera as soon as internal Roblox scripts change its position.
This is obviously a LocalScript
local subs = {
workspace.Subject1,
workspace.Subject2,
workspace.Subject3,
workspace.Subject4,
}
local TS = game:GetService("TweenService")
local RS = game:GetService("RunService")
local style = TweenInfo.new(2,Enum.EasingStyle.Linear)
local i = 1
local cam = workspace.Camera
local currentCFrame = cam.CFrame
local connection = nil
local function Intercept()
if cam.CFrame ~= currentCFrame then
connection:Disconnect()
cam.CameraType = Enum.CameraType.Scriptable
local target = {CFrame = cam.CFrame}
cam.CFrame = currentCFrame
local tween = TS:Create(cam,style,target)
tween:Play()
tween.Completed:Wait()
cam.CameraType = Enum.CameraType.Custom
end
end
while true do
currentCFrame = cam.CFrame
connection = RS.RenderStepped:Connect(Intercept)
cam.CameraSubject = subs[i]
i = i + 1
if i > #subs then
i = 1
end
task.wait(4)
end