Description
The WithY
method of the Vector2
struct allows you to create a new Vector2
instance with the same X component as the current instance, but with a specified Y component. This method is useful when you want to modify only the Y component of a vector while keeping the X component unchanged.
Usage
To use the WithY
method, call it on an existing Vector2
instance and pass the desired Y value as a parameter. The method returns a new Vector2
instance with the updated Y component.
Example
Vector2 originalVector = new Vector2(3.0f, 4.0f);
Vector2 newVector = originalVector.WithY(10.0f);
// newVector is now (3.0f, 10.0f)