What is the issue?
The issue is that, I can’t really make it work with an fps unlocker or when people have low fps.
As I record the recording with 60 fps, which means 60 keyframes per second. However, when play on a 30 fps pc, the max it can do is to go through 30 updates per second, which means playing 60 keyframes on a 30 fps pc is practically impossibe. However, after changing my fps on Parkour, it still works fine and even as smooth.
What solutions have you tried so far?
I have tried many wait modules, but the RunService.RenderStepped:Wait() yields depend on the fps. I did try to send remote event from the server’s Heartbeat so it can be constant 60 fps, but with a bad ping. The player won’t be able to enjoy this feature
I figured out how to make keyframes, and other stuff. But I really can’t figure out how to do wait() properly.
A piece of code to showcase how I am trying to loop through keyframes:
for _, keyframe in pairs(keyframes:GetChildren())
Torso.CFrame = keyframe.Torso.CFrameValue.Value
-- Other parts
RunService.RenderStepped:Wait()
end
Have you checked what wait() and RunService.RenderStepped:Wait() returns?
local kfs = keyframes:GetChildren()
local n = #kfs
local length = n/60
local elapsed = 0
local connection
connection = game['Run Service'].Heartbeat:Connect(function(dt)
elapsed += dt
Torso.CFrame = kfs[math.floor((elapsed/length) * n)].Torso.CFrameValue.Value --// could use some opmtization with the indexing.
if elapsed > length then connection:Disconnect() return end
end)
This of course assumes that the keyframes are created in order, which is what your loop demonstrated.
Might error if the length is too low (out of bounds).
I checked what wait() and RunService.RenderStepped:Wait() returns
most of them time I see wait() return 1/30 of a second (I can’t check it deeper since my fps unlocker minimum fps is 30)
while RunService.RenderStepped:Wait() return 1/fps of a second (it would be 1/240 of a second if your fps is 240)
The problem being, if you have 30 fps, and you run a 60 fps recording, it will give you a slow-motion effect, in this case, 0.5x of the normal time
However if you run a 60 fps recording in a 240 fps game, it would be 4x times as fast as normal. I could prevent the speed-up, but the slow-motion is unpreventable, as I couldn’t wait 1/60 of a second on a 30 fps game.
Well, I planned this whole system to be client-sided. There’s no point in making it server-sided, and to do that, it requires the client to have the same or above the amount of the fps in the recording. Thus ruining the experience of low fps players
Then whats the problem??
I see the problem not accounting for delta time to slow the animation for low fps players while it playing too fast for high fps players.
I can use delta time to prevent the speed-up, but I can’t prevent the slow-motion.
Taking the wait time for the low fps player * delta time will only make it even smaller, making it 1/60 of a second, which a 30 fps client can’t handle the wait()
the formula isn’t delta * wait time. Wait is never used and there’s only delta.
Anyhow, if the game is running at 30 fps, you cannot expect it to have 60 keyframes PLAYED per second, but in solution, the keyframes between it is jumped as it calculates the percentage towards n where n = #keyframes.