private void CalculateVelocity() { previousPosition = currentPosition; currentPosition = transform.position; currentVelocity = ((currentPosition - previousPosition).magnitude) / Time.deltaTime; // If using the PointOnPath method, velocity can change depending on the distance between nodes if (path.Length >= 2) { // Adjust the speed to compensate, unless too close to merit a change if (!CalculationFunctions.FastApproximately(currentVelocity, targetVelocity, 0.01f)) { Debug.Log("Calculating"); if (currentVelocity > targetVelocity) // Too fast, slow down { velocity -= (acceleration * Time.deltaTime); } else if (currentVelocity < targetVelocity) // Too slow, speed up { velocity += (acceleration * Time.deltaTime); } } } }