Description
The WithY
method of the Vector3
struct allows you to create a new Vector3
instance with a modified Y component, while keeping the X and Z components unchanged. This method is useful when you need to adjust only the Y value of a vector without affecting its other components.
Usage
To use the WithY
method, call it on an existing Vector3
instance and pass the new Y value as a parameter. The method returns a new Vector3
instance with the updated Y component.
Example
Vector3 originalVector = new Vector3(1.0f, 2.0f, 3.0f);
Vector3 modifiedVector = originalVector.WithY(5.0f);
// modifiedVector is now (1.0f, 5.0f, 3.0f)