Description
The Abs
method of the Vector2Int
struct returns a new Vector2Int
instance where each component of the vector is the absolute value of the corresponding component in the original vector. This means that any negative values in the vector are converted to positive values, while positive values remain unchanged.
Usage
Use the Abs
method when you need to ensure that all components of a Vector2Int
are non-negative. This can be useful in scenarios where directionality is not important, and you are only interested in the magnitude of each component.
Example
Vector2Int vector = new Vector2Int(-3, 4);
Vector2Int absoluteVector = vector.Abs();
// absoluteVector is now (3, 4)