Hey! Lately I have been trying to create my own first person camera system using RunService, CFrames and Lerps. During my Roblox Development, I’ve made 2 camera systems. Both were very FPS dependent and I’m trying to learn how to fix that.
What the question is really, which things do I use DeltaTime with?
Here’s something I made:
local RunService = game:GetService("RunService")
local Part = workspace:WaitForChild("Part")
local LerpAlphaValue = .1
RunService.RenderStepped:Connect(function(DeltaTime)
local Target = Part.CFrame * CFrame.new(0, .1, 0)
Part.CFrame = Part.CFrame:Lerp(Target, 1 - LerpAlphaValue ^ DeltaTime)
end)
(Lerp dependency issue fix, if you are curious: Frame rate independent lerp? - #18 by EmesOfficial)
So, from what I have tested, this runs finely and doesn’t have any FPS dependency issues. However, if I do
local Target = Part.CFrame * CFrame.new(0, 10 * DeltaTime, 0)
With the lerp calculation, the part goes faster on lower FPS, and slower on higher FPS.
I really really do not know where I should use DeltaTime, like if I should do it like that first example in the lerp, or if I just multiply DeltaTime with the desired target I want as the second example. I have tried searching for similar questions but none were helpful or at least for my situation
Thanks in advance!