Strange differences in lerp depending on framerate

I am trying to animate a model of a seal by lerping the size and C0.

Depending on the framerate, the seal seems to move more / less, even though all of the values add up to the correct values.

60 fps:


144 fps:
240 fps:

I haven’t tried much except for verifying that the equations do add up to the proper values. Any help / ideas appreciated.

After further testing, the calculated value and the value applied to the model are different.
image

-- Services --
local RunService = game:GetService("RunService")

-- Player --
local Character = script:FindFirstChild("Character").Value
local Humanoid: Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
local Seal: MeshPart = Character:WaitForChild("Seal")
local SealWeld: Weld = Seal:WaitForChild("SealWeld")

-- Numbers --
local sine = 0
local animationSpeed = 1

-- CFrames and Vectors and other really important maths stuff --
local SealOffset = CFrame.new(0, -1.75, 0)
local SealSize = Vector3.new(3.423, 2.87, 5.574)

local sin = math.sin
local cos = math.cos
local rad = math.rad

-- Functions --
local function onRenderStepped(deltaTime: number): nil
	sine += deltaTime * animationSpeed
	
	if Humanoid.MoveDirection.Magnitude <= 0.1 then
		animationSpeed = 10
		
		SealWeld.C0 = SealWeld.C0:Lerp(SealOffset, 0.1)
		Seal.Size = Seal.Size:Lerp(SealSize, 0.1)
		
	else
		animationSpeed = Humanoid.WalkSpeed
		
		Seal.Size = Seal.Size:Lerp(Vector3.new(0 - 0.75 * cos(sine), 0, 0 + 1 * sin(sine)) + SealSize, 0.1)
		SealWeld.C0 = SealWeld.C0:Lerp(CFrame.new(0, 0.15 + 0.15 * sin(sine), 0) * CFrame.Angles(rad(0 + 10 * cos(sine)), 0, 0) * SealOffset, 0.1)
	end
	
	return
end

-- Connections --
RunService:BindToRenderStep(script.Name, Enum.RenderPriority.Character.Value, onRenderStepped)

1 Like

Update: Seal.Size.X at it’s highest is around 3.66 on 60 fps, around 3.9 on 240 fps.

It should be around 4.1 unless I’m missing something?

Changing the lerp’s alpha from 0.1 to 1 fixed the issue!

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