Hey,
I am making smooth cutscene. I used before parts as a camera positions but I have to use like 50 different Parts in one cutscene. So I tried to set camera CFrame to player head’s CFrame. It is almost working but there are 2 problems:
- shake
- camera sometimes looks different way than it should
Here are the code and video where you can see the problem. Yeah, yeah… there are many different posts about this but I try to make smooth cutscenes and I do things a bit differently.
Code:
local camera = game.Workspace.CurrentCamera
local cutscenesFolder = game.Workspace:FindFirstChild("Cutscenes").Chase
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")
local function startCutscene(duration)
local character = player.Character
if not character then return end
local head = character:FindFirstChild("Head")
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not (head and humanoid and camera) then return end
local startTime = tick()
local offsetDistance = -1
local connection
connection = runService.RenderStepped:Connect(function()
local elapsedTime = tick() - startTime
if elapsedTime >= duration then
connection:Disconnect()
camera.CameraType = Enum.CameraType.Custom
humanoid.CameraOffset = Vector3.new(0, 0, -1)
return
end
local headCFrame = head.CFrame
local newCameraCFrame = headCFrame * CFrame.new(0, 0, offsetDistance)
camera.CFrame = head.CFrame--CFrame.lookAt(newCameraCFrame.Position, headCFrame.Position + headCFrame.LookVector)
humanoid.CameraOffset = Vector3.new(0, 0, -1)
end)
end
local hposes = {
cutscenesFolder.Hpos,
cutscenesFolder.Hpos2,
cutscenesFolder.Hpos3,
cutscenesFolder.Hpos4,
cutscenesFolder.Hpos5,
cutscenesFolder.Hpos6,
cutscenesFolder.Hpos7
}
local function startHRP()
tweenService:Create(player.Character.HumanoidRootPart, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = hposes[1].CFrame}):Play()
wait(0.1)
tweenService:Create(player.Character.HumanoidRootPart, TweenInfo.new(2.9, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = hposes[2].CFrame}):Play()
wait(7.6)
tweenService:Create(player.Character.HumanoidRootPart, TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = hposes[3].CFrame}):Play()
wait(0.57)
tweenService:Create(player.Character.HumanoidRootPart, TweenInfo.new(0.73, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = hposes[4].CFrame}):Play()
wait(2.73)
tweenService:Create(player.Character.HumanoidRootPart, TweenInfo.new(6, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = hposes[5].CFrame}):Play()
wait(17)
tweenService:Create(player.Character.HumanoidRootPart, TweenInfo.new(0.2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = hposes[6].CFrame}):Play()
wait(5.4)
tweenService:Create(player.Character.HumanoidRootPart, TweenInfo.new(0.6, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = hposes[7].CFrame}):Play()
wait(0.6)
end
fol.Chaseblocks.colliderfirst.Touched:Connect(function(Hit)
camera.CameraType = Enum.CameraType.Scriptable
game.Players.LocalPlayer:WaitForChild("CutsceneLock").Value = true
wait()
player.Character.Humanoid.WalkSpeed = 0
wait()
player.Character.HumanoidRootPart.Anchored = true
player.Character.Humanoid.AutoRotate = false
task.spawn(function()
startCutscene(34)
end)
startHRP()
camera.CameraType = Enum.CameraType.Custom
game.Players.LocalPlayer:WaitForChild("CutsceneLock").Value = false
player.Character.Humanoid.WalkSpeed = 20
player.Character.HumanoidRootPart.Anchored = false
player.Character.Humanoid.AutoRotate = true
end)
Video:
I would like to get help asap. I am still trying to fix this by myself but I haven’t found any solutions yet.