/** Finds the closest point on the current path and configures the #interpolator */ protected virtual void ConfigureNewPath() { var hadValidPath = interpolator.valid; var prevTangent = hadValidPath ? interpolator.tangent : Vector3.zero; interpolator.SetPath(path.vectorPath); interpolator.MoveToClosestPoint(GetFeetPosition()); if (interpolatePathSwitches && switchPathInterpolationSpeed > 0.01f && hadValidPath) { var correctionFactor = Mathf.Max(-Vector3.Dot(prevTangent.normalized, interpolator.tangent.normalized), 0); interpolator.distance -= speed * correctionFactor * (1f / switchPathInterpolationSpeed); } }