I have smooth rotation for the spinner, however on lower framerates the spinner seems to remove elasticity and on very low framerates it starts to increase speed when it should be decreasing/still.
The issue comes from the elasticity, as removing it from distance seems to result in less issues. The delta calculations are currently a mess but I couldn’t find a better way of implementing it. I tried looking for help on both delta and the elasticity issue and didn’t see any posts about this. Any help is appreciated!
local MaxSpeedSecond = 400
local CurrentSpeed = 0
-- Lerps the rotation with elasticity
local function LerpAngle(Start: number, Target: number, Elasticity: number, delta: number): number
Target %= 360 Start %= 360
local Difference = Target - Start
-- Takes shortest path
Difference = FixOverRotation(Difference)
-- Applies current speed
local Distance = math.clamp(Difference * Elasticity, -MaxSpeedSecond, MaxSpeedSecond)
CurrentSpeed = math.lerp(CurrentSpeed, Distance, math.min(10 * delta, 1))
local Current = (Start + CurrentSpeed * delta) % 360
return FixOverRotation(Current)
end
- 120 fps, the elasticity works as intended
- 10 fps, it removes elasticity
- 4 fps, the elasticity gains speed