Of course I am using renderstep. But it just doesn’t work well at all with an fps unlocker.
Is there any way of actually finding a good rate for both capped and uncapped FPS that doesnt involve just guessing numbers?
It appears to work a lot better now, however the gun model keeps jittering.
Accumulated += dt
while Accumulated >= Rate do
Accumulated -= Rate
ViewModel.Torso.CFrame = Camera.CFrame
updateArm("Right") -- Place arm on weapon
if Character:FindFirstChildWhichIsA("Tool") then
local rotation = workspace.CurrentCamera.CFrame:toObjectSpace(lastCameraCF)
local x,y,z = rotation:ToOrientation()
local Tool = ViewModel:FindFirstChildWhichIsA("Model")
-- Calculate sway of gun
swayOffset = swayOffset:Lerp(CFrame.Angles(math.sin(x)*mult,math.sin(y)*mult, 0), 0.1)
ViewModel.Torso.CFrame = Camera.CFrame * swayOffset;
Tool.InvisParts.BodyAttach.CFrame = ViewModel:FindFirstChildWhichIsA("Model").InvisParts.BodyAttach.CFrame
lastCameraCF = Camera.CFrame
-- Tool movement bobbing using springs
local bob = Vector3.new(Bobbing(10),Bobbing(5),Bobbing(5))
bobbing:shove(bob / 10 * (Character.HumanoidRootPart.Velocity.Magnitude / 10))
local updatebob = bobbing:update(dt)
ViewModel.Torso.CFrame =ViewModel.Torso.CFrame:ToWorldSpace(CFrame.new(updatebob.Y, updatebob.X, 0))
Honestly got no clue with the variable naming like mult
TL;DR, make sure to use delta time, the spring module bobbing already uses delta time no need to adjust for that.
The issue is the sway which doesn’t use delta time, this should be within the while loop accumulator to make it adjust for delta time at constant rate independent of frame rate.
However I suspect the bobbing is causing the jittering because of the :update(dt) within the while loop, I suspect the spring update dt is already adjusted for delta time so there is no need to put this section in the while loop. Currently I believe it’s updating too much in a single frame causing the jitter.
Only the lerp parts are not adjusted for the delta time because the lerp alpha is constant 0.1 and not based on delta time as seen here, this part should be rate limited to make it delta time based and framerate independent.
Referencing this piece of code, perhaps you could try replacing the alpha value of 0.1 with something along the lines of 6*dt, representing the alpha value per second you feel works at presumably 60 fps, or 60 fps * 0.1 a = 6
This might make it completely freak out for people with and FPS lower than like 30, but perhaps we will be able to take a partial solution and build upon it, given this topic seems to have died a bit (This is assuming you remove the accumulator)
If youre comfortable sharing some of the models Id love to not waste your time suggesting 50 different things which could be tested in just 10 minutes, additionally, but this is by no means necessary
I believe this problem has already been solved before within this tutorial which uses the same delta time strategies to account for the additional fps me and @PapaBreadd have been trying to suggest the entire time.
One such method is the spring method I linked above and also found in the fps framework tutorial below:
Theoretically this should work because it’s been there for a long time and made by a experienced fps developer. If it doesn’t work for you then…