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.

Usage

To use the Clamp method, call it on an instance of Vector3 and provide two Vector3 parameters representing the minimum and maximum bounds. The method will return a new Vector3 where each component is clamped between the corresponding components of the otherMin and otherMax vectors.

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)