Hey Developers!
I’m currently working on a new project that I’m very passionate about, and I am excited to see where I can take it and hopefully showcase it sometime in the future.
However, I’m having some trouble with a core function of this project. Because it is rhythm-based, I need to perform many calculations within a short period of time for the system to function properly.
Because of this requirement, It is hard to determine what the best solution is for keeping the rhythm and making sure nothing feels offbeat, even when the framerate drops below 60FPS.
Here’s a portion of my code, which relies on RunService.RenderStepped
to determine when a sound should be played.
rns.RenderStepped:Connect(function()
local currentTime = script.Tutorial.TimePosition
for i,v in pairs(keyTimes) do
for ii,vv in pairs(v) do
if script.Tutorial.TimePosition >= vv and script.Tutorial.TimePosition <= vv+.1 then
table.remove(v,ii)
print("Get Ready...")
script:FindFirstChild(i):Play()
break
end
end
end
end)
I have attempted both RunService.Heartbeat
and task.wait()
, but the current method seems to be the most effective.
However, when performance drops, RenderStepped
will call less frequently, resulting in a slightly offbeat feel that makes it nearly impossible to match the rhythm when the framerate drops to or below 30FPS. (which is obviously common on lower-end devices)
Here’s a video clip of the game running with FPS unlocked: (behaves almost identical to 60FPS)
And here’s a clip of the game running with FPS locked at 30:
If you need any more information to help please let me know.
Thanks!