So i have this system where the flashlight moves first then the camera lerps into position as shown here
https://gyazo.com/09e6ea4599570251edd5f1c83b3a75d8.mp4
the issue is that since it’s using lerp if you do a 360 as you would do in most horror situations, the fastest way is the opposite way so it doesn’t work as intended.
i have no idea how to fix this as i can’t just put a cap on the turning speed.
this is the video im using as reference:
https://gyazo.com/452dfb112a6e8d4b3d22a51fc8992b93
this is the current script that does it but not as intended
local rs = game:GetService("RunService")
local cam = workspace.CurrentCamera
local uis = game.UserInputService
local lastc: CFrame?
local currentc: CFrame?
local headlight = script.Headlight
headlight.Parent = workspace
local TurnFactor = 7
local SwayFactor = 0.1
rs:BindToRenderStep("BeforeCamera", Enum.RenderPriority.Camera.Value - 1, function(dt)
if lastc then
cam.CFrame = lastc
headlig ht.CFrame = lastc
end
end)
rs:BindToRenderStep("AfterCamera", Enum.RenderPriority.Camera.Value + 1, function(dt)
local move = uis:GetMouseDelta().X
local sway = CFrame.Angles(0,0,math.rad(move * SwayFactor))
lastc = cam.CFrame
currentc = (currentc or lastc).Rotation:Lerp(lastc.Rotation, math.min(1, dt * TurnFactor)) * sway
cam.CFrame = CFrame.new(cam.CFrame.Position) * currentc
end)