The x
property of the Vector3
struct represents the X component of a 3D vector. This component is a single-precision floating-point value (System.Single
), which is commonly used to define the horizontal position in a 3D space.
The x
property of the Vector3
struct represents the X component of a 3D vector. This component is a single-precision floating-point value (System.Single
), which is commonly used to define the horizontal position in a 3D space.
Use the x
property to access or modify the X component of a Vector3
instance. This property is not static, so it must be accessed through an instance of Vector3
.
// Example of accessing and modifying the x component of a Vector3 Vector3 position = new Vector3(1.0f, 2.0f, 3.0f); // Access the x component float xValue = position.x; // Modify the x component position.x = 5.0f; // Output the modified Vector3 // position is now (5.0, 2.0, 3.0)