I tried to make a first person camera function with 1 frame delayed to achieve the accelerate, decelerate and turning effect. But somehow it also produce a laggy camera effect.
Codes below:
local RunService = game:GetService("RunService")
local cam = workspace.CurrentCamera
function FirstPerson(haveDelay)
local saveCam;
RunService:BindToRenderStep("DrivingCamFirstPerson", Enum.RenderPriority.Camera.Value, function(dt)
cam.CameraType = "Scriptable"
local hhead = game.Players.LocalPlayer.Character.Head
local rx, ry, rz = hhead.CFrame:ToOrientation()
local newcor = CFrame.new(hhead.Position) * CFrame.fromOrientation(0, ry, rz) --remove angle x from the original cframe
if haveDelay then
if saveCam then
cam.CFrame = saveCam --use the last CFrame
end
saveCam = newcor --save the camera CFrame
else
cam.CFrame = newcor
end
end)
end
From using FirstPerson(false) (First person camera without delay effect), the camera move smoothly
But for FirstPerson(true) (First person camera with delay effect), the camera move laggy.
Heres some help, utilize springs/dampening. Why? Think of it as this (I saw somebody explain this), if you’re moving the camera over and over to another part on lerp it’d keep changing as it moves meaning it never actually has any “velocity” to the camera, its just triyng to follow where you’d assign it.
Now if you were to use springs, it will keep moving forward smoothly until you stop or it finally reaches the destination. This allows for smooth camera movement, you can check this post out to help you:
(Its old but it will help, just search for the replies with dampening and springs)
The spring method works but it is not suitable in my situation, mine is first person view and there are things at the back. The camera will clipped into the wall and go to the back of the vehicle if the speed is too fast which is not realist as first person driver.
If I’m not mistaken, they use springs/dampening in first person cameras. You just need to alter the settings and so on for it to work correctly in your game. (though I may be wrong )