Make an animation based on mouse movement play smoother?

Hi, i’m trying to make a system where u play an animation, but only if you moved your mouse enough on the X axis. I sort of achieved what i wanted but it’s not very smooth… How would i make it more smooth?

Mouse.Move:Connect(function()
	local deltaCurrent = Vector2.new(Mouse.X, Mouse.Y)
	deltaCurrent = deltaCurrent - prevDelta
	prevDelta += deltaCurrent 
	
	if deltaCurrent.X > 50 then
		if MixingAnimation.IsPlaying == false then
			MixingAnimation:Play()
		else
			MixingAnimation:AdjustSpeed(deltaCurrent.X/150)
		end
	else
		MixingAnimation:AdjustSpeed(0)
	end
end)


Thanks in advance!

deltaCurrent -= prevDelta
prevDelta = deltaCurrent 

Just from an initial glance, I noticed the two values were just being toggled between (unless that was intended). The above will correctly update the most recent mouse delta.

1 Like

Sorry but that only makes the arm trip?