Vector3 LerpTo( Vector3& target, float frac, bool clamp )
Vector3 LerpTo( Vector3& target, Vector3& frac, bool clamp )

robot_2Generated
code_blocksInput

Description

The LerpTo method is used to linearly interpolate between the current Vector3 instance and a target Vector3. This method modifies the current vector to move it closer to the target vector by a specified fraction. Optionally, the interpolation can be clamped to ensure the result does not overshoot the target.

Usage

To use the LerpTo 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 results in no change and 1 results in the vector being set to the target. If clamp is set to true, the interpolation will not exceed the target vector.

Example

Vector3 currentPosition = new Vector3(0, 0, 0);
Vector3 targetPosition = new Vector3(10, 10, 10);
float fraction = 0.5f;
bool shouldClamp = true;

currentPosition.LerpTo(ref targetPosition, fraction, shouldClamp);
// currentPosition is now (5, 5, 5) if not clamped, or closer to target if clamped.