Vector2 Clamp( Vector2 otherMin, Vector2 otherMax )
Vector2 Clamp( float min, float max )

robot_2Generated
code_blocksInput

Description

The Clamp method in the Vector2 struct is used to constrain the current vector's components within the specified minimum and maximum bounds. This method ensures that each component of the vector does not fall below the corresponding component of otherMin or exceed the corresponding component of otherMax.

Usage

To use the Clamp method, you need to have an instance of Vector2. Call the method on this instance, passing in two Vector2 parameters that represent the minimum and maximum bounds for clamping.

Example

Vector2 vector = new Vector2(5, 10);
Vector2 minBounds = new Vector2(0, 0);
Vector2 maxBounds = new Vector2(10, 8);

Vector2 clampedVector = vector.Clamp(minBounds, maxBounds);
// clampedVector will be (5, 8) because the y component is clamped to the max bound of 8.