The WithY
method of the Vector3Int
struct allows you to create a new Vector3Int
instance with a specified Y component, while keeping the X and Z components unchanged from the original vector.
The WithY
method of the Vector3Int
struct allows you to create a new Vector3Int
instance with a specified Y component, while keeping the X and Z components unchanged from the original vector.
Use this method when you need to modify the Y component of a Vector3Int
without altering its X and Z components. This is useful in scenarios where you want to adjust the vertical position or height of a vector while maintaining its horizontal position.
Vector3Int originalVector = new Vector3Int(1, 2, 3); Vector3Int newVector = originalVector.WithY(5); // newVector is now (1, 5, 3)