Vector3 WithY( float y )

book_4_sparkGenerated
code_blocksInput

Description

The WithY method of the Vector3 struct allows you to create a new Vector3 instance with a specified Y component, while keeping the X and Z components unchanged. This method is useful when you need to modify only the Y component of a vector without affecting the 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 newVector = originalVector.WithY(5.0f);
// newVector is now (1.0f, 5.0f, 3.0f)