Vector2 LerpTo( Vector2 target, float t, bool clamp )
Vector2 LerpTo( Vector2 target, Vector2 t, bool clamp )

book_4_sparkGenerated
code_blocksInput

Description

The LerpTo method is an instance method of the Vector2 struct that interpolates between the current vector and a target vector. The interpolation is controlled by a parameter t, which represents the interpolation factor. The method can optionally clamp the result to ensure it remains between the start and target vectors.

Usage

To use the LerpTo method, call it on an instance of Vector2, passing in the target vector, the interpolation factor t, and a boolean indicating whether to clamp the result. The method returns a new Vector2 that is the result of the interpolation.

The interpolation factor t 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 result will be clamped between the original and target vectors.

Example

Vector2 start = new Vector2(0, 0);
Vector2 target = new Vector2(10, 10);
float t = 0.5f;
bool clamp = true;

Vector2 result = start.LerpTo(target, t, clamp);
// result is (5, 5) if clamp is true, otherwise it may exceed the target if t > 1