local totalTime = 0
local stepTime = 1/120
function renderStep(dt)
totalTime = math.min(totalTime+dt,1)
while totalTime > stepTime do
-- also tried with and without dt*60
springs.walk:shove((bob / config.bobDivisor) * velocity.Magnitude)
springs.camera:shove((camBob / config.camBobDivisor) * velocity.Magnitude)
totalTime-=stepTime
end
end)
I’ve also tried different equations for scaling on deltatime, none worked:
1-math.exp(-x*dt)
dt / (1/60)
Every devforum post I saw did not solve my issue, even when using springs.
tl;dr
bobbing speed and size using springs is dependent on fps when scaling by deltatime i need it to be the same on all fps values
-- also tried putting dt*60 at the end same result
local n = 1-math.exp(-100*dt)
-- spring shoving
springs.walk:shove((bob / config.bobDivisor) * velocity.Magnitude * n)
springs.camera:shove((camBob / config.camBobDivisor) * velocity.Magnitude * n)
springs.sway:shove(newVector3(0, -(mouseDelta.x / config.swayDivisor), mouseDelta.y / config.swayDivisor)) -- dont think this needs to be scaled with dt
-- spring updates
local modelSpring, swaySpring, camSpring, walkSpring, modelRotSpring =
springs.model:update(dt), springs.sway:update(dt), springs.camera:update(dt), springs.walk:update(dt), springs.modelRot:update(dt)
-- this is how i set the cframes (very hard to read)
camera.CFrame = camera.CFrame * newAngles(camSpring.x,camSpring.y,camSpring.z) * camRoll
viewmodel:PivotTo(camera.CFrame * newCFrame(walkSpring.x+modelSpring.x, modelConstantOffset.Y+walkSpring.y+modelSpring.y, modelConstantOffset.Z+modelSpring.z+walkSpring.z) * newAngles(modelRotSpring.x+walkSpring.x+swaySpring.x,modelRotSpring.y+swaySpring.y+walkSpring.y,modelRotSpring.z+swaySpring.z) * modelOffsetLerp)
you’re shoving the spring every frame which would shove the springs more or less depending on how many frames per second there are. is there any way of setting a “target” for the spring of sorts?