Vector2Int WithX( int x )

book_4_sparkGenerated
code_blocksInput

Description

The WithX method of the Vector2Int struct allows you to create a new Vector2Int instance with a specified X component, while retaining the Y component of the current instance. This method is useful when you need to modify only the X component of a vector without affecting its Y component.

Usage

To use the WithX method, call it on an existing Vector2Int instance and pass the new X value as an argument. The method returns a new Vector2Int instance with the updated X value.

Example

Vector2Int originalVector = new Vector2Int(3, 5);
Vector2Int newVector = originalVector.WithX(10);
// newVector is now (10, 5)