while true do
local DT = game:GetService("RunService").Heartbeat:Wait()
local movement = 60/DT
--positions
number = number + 1
local position = (4*100*DT) * number --4 is the length of each part in the projectile, 100 is the speed and dt is the delta time
end
It seems weird for that to happen. The value returned by the Heartbeat event should be the time in seconds since the previous frame, so ‘DT’ should be smaller if the frame rate is higher.
Have you tried running to benchmark to see if the FPS unlocker actually changes that?
local rs = game:GetService("RunService")
local frameCount = 0
local timeCount = 0
repeat
timeCount = timeCount + rs.Heartbeat:Wait()
frameCount = frameCount + 1
until (timeCount >= 10)
print(frameCount)
If you ran something like this once without the unlocker then with it turned on, the difference in the frame counters should be about proportional to the change in FPS
That’s some strange behavior and is definitely going to change a few things about how my stuff is coded. Thank you for posting this.
As a fix, you could try measuring the timestep yourself:
while true do
local tStart = os.clock()
game:GetService("RunService").Heartbeat:Wait()
local DT = os.clock() - tStart
--Remainder of your code here
end
os.clock() directly talks to your CPU clock and thus should give you a more accurate measurement.
You don’t need to divide 60 by DT anyway. Multiplying the pre-defined velocity by DT will result in the distance the object should move in that one frame.
Interesting. I do have a question before I make any further assumptions:
You have the line local movement = 60/DT. What is this used for? Keep in mind, DT is a time in seconds, so movement will actually be a higher value for higher framerates. If you’re basing the projectile’s movement on this, there’s no surprise it’s moving faster at higher framerates.
Your position calculation is more correct for what you’re trying to achieve.
Keep in mind as well that framerates can be unstable, especially with an FPS unlocker. This can cause choppy behavior.
Trying to force the loop to run at a specific rate is probably what caused your issue in the first place. You should write your scripts to be able to run at any physics rate. That’s part of why functions like wait() and RenderStepped:Wait() return the amount of time that was yielded - so you can use that value to accurately move things at the speed you want.
Nvm it’s doesn’t do anything, I’m trying to make it run at 60 fps no matter what. I might just make a script to kick you if you’re using an fps unlocker because nothings working. https://gyazo.com/7b81ee8d6da5d2013ee4a72601912f68