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

book_4_sparkGenerated
code_blocksInput

Description

The Clamp method in the Vector3 struct is used to constrain each component of the vector to be within the specified minimum and maximum values. This method ensures that the resulting vector's components do not exceed the specified bounds.

Usage

To use the Clamp method, call it on an instance of Vector3 and provide two Vector3 parameters: otherMin and otherMax. These parameters represent the minimum and maximum bounds for the vector components, respectively.

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)