Projectile Travelling Slower When FPS Is Reduced

I have this problem where projectiles travel much slower when FPS is below 60. Video showing it:

Above 60 fps:

30 fps:

The code I currently have:

hr = game:GetService("RunService").Heartbeat:Connect(function(dt)

	local margin = 0.01 * 60
	local pos = --not leaking the code

	bullet.CFrame = -- not leaking the code
	aim = aim - drop
1 Like

RunService.Heartbeat is based off the player’s frame per second, so pretty much the lower the FPS the less the Heartbeat event would be fired.

This also means that if the FPS is over 30 FPS, then the heartbeat event will be fired 30 times per second.

EDIT 1: Added link
EDIT 2: More details

You should account for the delta time passed when changing the position, dt is the delta time

The position is based on velocity and time, so you should take time into account. dt is delta time also known as the change in time, and to calculate the change in position with that is to do dt*velocity

I don’t really know what most of your code is really doing but probably change margin to be:

local margin = 36*dt

I solved my own problem by just multiplying drop with the dt. Thanks to everyone that helped and especially @TheGrandBraker for suggesting to multiply the delta!

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