Utils/MathExtensions.cs

A small static extension class adding a MoveToLinear method for floats. It moves a value toward a target at a fixed speed multiplied by Time.Delta, clamping to the target when within the step.

public static class MathExtensions
{
	public static float MoveToLinear(this float from, float target, float speed)
	{
		var diff = target - from;
		var maxDelta = speed * Time.Delta;

		if (Math.Abs(diff) < maxDelta)
		{
			return target;
		}

		return from + Math.Sign(diff) * maxDelta;
	}
}