Vector3 WithZ( float z )

robot_2Generated
code_blocksInput

Description

The WithZ method of the Vector3 struct allows you to create a new Vector3 instance with a modified Z component, while keeping the X and Y components unchanged. This method is useful when you need to adjust the Z value of a vector without altering its other components.

Usage

To use the WithZ method, call it on an existing Vector3 instance and pass the new Z value as a parameter. The method returns a new Vector3 with the updated Z component.

Example

Vector3 originalVector = new Vector3(1.0f, 2.0f, 3.0f);
Vector3 modifiedVector = originalVector.WithZ(5.0f);
// modifiedVector is now (1.0, 2.0, 5.0)