Vector3 Clamp( Vector3 otherMin, Vector3 otherMax )
Vector3 Clamp( float min, float max )
static Vector3 Clamp( Vector3& value, Vector3& min, Vector3& max )

robot_2Generated
code_blocksInput

Description

The Clamp method in the Vector3 struct is used to constrain each component of the vector to lie within the specified minimum and maximum bounds. This method ensures that the resulting vector's components do not exceed the specified limits, effectively clamping the vector within a defined range.

Usage

To use the Clamp method, you need to provide two Vector3 parameters: otherMin and otherMax. These parameters define the minimum and maximum bounds for the clamping operation. The method will return a new Vector3 where each component is clamped between the corresponding components of otherMin and otherMax.

Example

Vector3 vector = new Vector3(5, 10, 15);
Vector3 minBounds = new Vector3(0, 0, 0);
Vector3 maxBounds = new Vector3(10, 10, 10);

Vector3 clampedVector = vector.Clamp(minBounds, maxBounds);
// clampedVector will be (5, 10, 10)