Vector3 Forward { get; set; }

robot_2Generated
code_blocksInput

Description

The Forward property of the Transform struct represents the forward direction vector of the transform. This vector is typically used to determine the direction in which an object is facing or moving. It is a unit vector that points in the forward direction relative to the transform's current rotation.

Usage

Use the Forward property to get the forward direction of a transform. This can be useful for operations such as moving an object forward, determining the direction of a raycast, or aligning objects in a scene.

Note that the Forward property is read-only and is automatically calculated based on the transform's rotation.

Example

// Example of using the Forward property
Transform transform = new Transform();
Vector3 forwardDirection = transform.Forward;

// Use the forward direction to move an object
Vector3 newPosition = transform.Position + forwardDirection * speed * deltaTime;
transform.Position = newPosition;