UI elasticity not working as intended on lower framerates

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
1 Like

I’m assuming that you are lerping through RenderStepped. If so, get the DeltaTime in your renderstepped and do some weird math, I’m not entirely sure but I think it will be

--lerp's delta is 0.2, for example
whatever:Lerp(goal,0.2/(Delta*60)-- you can change 60 to whatever but it just gives a good relative when deciding a good value to use for your lerps
-- delta is the one from RenderStepped.

I tested the thing above and it doesn’t work so just do Vector:Lerp(End, 1 - 0.001 ^ DeltaTime)
or math.lerp(End, 1 - 0.001 ^ DeltaTime) the more zeroes you add the faster it will move

Thanks, I was able to get it to work with this and some other changes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.