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, you need to provide a target vector, a fraction value, and a boolean indicating whether to clamp the result. The fraction value should be between 0 and 1, where 0 returns the current vector and 1 returns the target vector. If clamping is enabled, the result will be clamped to ensure it does not exceed the target vector.
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.