Transform EyeTransform { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The EyeTransform property of the PlayerController class provides the player's eye position in first-person mode. This property is useful for determining the player's viewpoint and orientation in the game world, especially when rendering the first-person perspective or calculating interactions based on the player's line of sight.

Usage

Use the EyeTransform property to access the player's eye position and orientation in the game world. This can be particularly useful for tasks such as aligning the camera to the player's view, determining what the player is looking at, or calculating the direction of projectiles or interactions.

Example

// Example of using EyeTransform to get the player's eye position and orientation
Transform eyeTransform = playerController.EyeTransform;

// Use the eye position for a raycast
Vector3 eyePosition = eyeTransform.Position;
Vector3 eyeDirection = eyeTransform.Forward;

// Perform a raycast from the eye position in the direction the player is looking
SceneTraceResult result = Scene.Trace.Ray(eyePosition, eyePosition + eyeDirection * 1000).Run();

if (result.Hit)
{
    // Do something with the hit result
    GameObject hitObject = result.Entity;
    // Example: Log the name of the object hit
    Log.Info($"Hit object: {hitObject.Name}");
}