Description
The Vector3.SlerpTo
method performs a spherical linear interpolation (slerp) between the current vector and a target vector. This method is useful for smoothly interpolating between two vectors, such as for animations or gradual transitions in 3D space.
Usage
To use the SlerpTo
method, call it on an instance of Vector3
, passing in the target vector, the interpolation fraction, and a boolean indicating whether to clamp the result.
The frac
parameter should be a value between 0 and 1, where 0 returns the original vector and 1 returns the target vector. If clamp
is set to true
, the interpolation will be clamped to the range [0, 1].
Example
Vector3 current = new Vector3(1, 0, 0);
Vector3 target = new Vector3(0, 1, 0);
float fraction = 0.5f;
bool clamp = true;
Vector3 result = current.SlerpTo(ref target, fraction, clamp);
// result will be a vector halfway between current and target on the unit sphere.