Vector3 Forward { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Forward property of the Ray struct represents the direction in which the ray is pointing. It is a Vector3 that defines the ray's direction in 3D space.

Usage

Use the Forward property to determine or set the direction of a ray. This is useful in scenarios where you need to calculate intersections, reflections, or simply understand the orientation of the ray in the scene.

Example

// Example of using the Ray struct and its Forward property
Ray ray = new Ray();
ray.Position = new Vector3(0, 0, 0); // Set the origin of the ray
ray.Forward = new Vector3(1, 0, 0); // Set the direction of the ray

// Use the Forward property to get the direction
Vector3 direction = ray.Forward;

// Output the direction
// Note: Avoid using Console.WriteLine in s&box
// Instead, use in-game debugging tools or loggers
Debug.Log($"Ray direction: {direction}");