60+ FPS breaks view bobbing

So I have a view bobbing script that works perfectly fine with 60 fps capped. As soon a fps unlocker is used it starts speeding up. To counter this I used deltaTime but it is still doing it. Any suggestions? Here is a snippet of the code.

local Tick = tick()
local CameraBobbleZ
local CameraBobbleY

if Humanoid.WalkSpeed < 32 then
	speed = 8
	intensity = 0.005
else
	speed = 8
	intensity = 0.6
end
		
CameraBobbleZ = math.sin(Tick * speed) * intensity -- 8, 0.01
CameraBobbleY = math.sin(Tick * speed) * intensity -- 6, 0.01

local ResultCFrame = CFrame.Angles(CameraBobbleY,0,CameraBobbleZ)
		
OriginalCFrame = OriginalCFrame:Lerp(ResultCFrame, math.clamp(.1 * dt * 60, 0, 1) )
2 Likes

multiply everything by this:

local ratio = 60 / (1/dt)

it multiplies by 1 at 60 fps

60 / (1/(1/60)) = 1

and corrects anything over that

60/(1/(1/120)) = 0.5

What exactly am I multiplying? I tried this and it had the same result as before.

local ratio = 60 / (1/dt)
OriginalCFrame = OriginalCFrame:Lerp(ResultCFrame, math.clamp(.1 * ratio, 0, 1) )
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.