The LerpTo
method is used to interpolate the current Vector3
instance towards a target Vector3
using linear interpolation. This method modifies the current vector to move it closer to the target vector based on the specified fraction.
The LerpTo
method is used to interpolate the current Vector3
instance towards a target Vector3
using linear interpolation. This method modifies the current vector to move it closer to the target vector based on the specified fraction.
To use the LerpTo
method, call it on an instance of Vector3
and provide 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 results in no change and 1 results in the current vector being set to the target vector. If clamp
is set to true
, the interpolation will be clamped to ensure the result does not overshoot the target.
Vector3 currentPosition = new Vector3(0, 0, 0); Vector3 targetPosition = new Vector3(10, 10, 10); float interpolationFraction = 0.5f; bool shouldClamp = true; currentPosition.LerpTo(ref targetPosition, interpolationFraction, shouldClamp); // currentPosition is now halfway between its original position and targetPosition.