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

robot_2Generated
code_blocksInput

Description

The LerpTo method is an instance method of the Vector2 struct that interpolates between the current vector and a target vector by a specified fraction. This method is useful for smooth transitions between two vectors over time.

Usage

To use the LerpTo method, call it on an instance of Vector2, passing in the target vector, the interpolation fraction, and a boolean indicating whether to clamp the result between the start and target vectors.

The t parameter should be a value between 0 and 1, where 0 returns the start vector and 1 returns the target vector. If clamp is set to true, the result will be clamped to the range defined by the start 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 will be (5, 5) if clamp is true, as it is halfway between start and target.