The Vector3.Lerp
method performs a linear interpolation between two vectors, a
and b
, based on a given fraction frac
. This method is useful for smoothly transitioning between two points in 3D space.
The Vector3.Lerp
method performs a linear interpolation between two vectors, a
and b
, based on a given fraction frac
. This method is useful for smoothly transitioning between two points in 3D space.
To use the Vector3.Lerp
method, provide two Vector3
instances representing the start and end points, a float
value for the interpolation fraction, and a bool
indicating whether to clamp the fraction between 0 and 1. If clamp
is set to true
, the fraction will be constrained to the range [0, 1], ensuring the result is always between a
and b
.
Vector3 start = new Vector3(0, 0, 0); Vector3 end = new Vector3(10, 10, 10); float fraction = 0.5f; bool clamp = true; Vector3 result = Vector3.Lerp(start, end, fraction, clamp); // result is (5, 5, 5) if clamp is true, otherwise it could be outside the range if fraction is outside [0, 1]