How would I make this not depend on the framerate?

Hey there! I have made a slide mechanic, which works fine, besides the camera movement. It goes way faster on higher framerates, how would I fix this?

script:

offsetLoop = runService.RenderStepped:Connect(function()
	humanoid.CameraOffset = humanoid.CameraOffset - Vector3.new(0,.25,0)
end)

I don’t want it to depend on the server by the way, it’s a singleplayer game and I am doing nearly everything in localscripts to make sure it runs as smooth as possible, without depending on the server.

You’ll wanna use DeltaTime which you can get from the function :Connect(function(DeltaTime).
I don’t really know how to implement it in this case so just look up how to I guess :man_shrugging:

If you use the first argument of RenderStepped, which is deltaTime, you can scale the 0.25 offset to change based off of your deltaTime.

I’m pretty sure this should work fine…?

local normalDelta = (1 / 60) -- assuming 60FPS is the base of your effect

offsetLoop = runService.RenderStepped:Connect(function(deltaTime)
	humanoid.CameraOffset = humanoid.CameraOffset - Vector3.new(0, (0.25 * (deltaTime / normalDelta)), 0)
end)
4 Likes

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