Description
The EyePosition
property of the PlayerController
class represents the position of the player's eyes in first-person mode. This property is crucial for determining where the player is looking from, which can be used for various gameplay mechanics such as aiming, interacting with objects, or rendering the player's view.
Usage
To access the player's eye position, you can use the EyePosition
property directly from an instance of PlayerController
. This property returns a Vector3
representing the 3D coordinates of the player's eyes.
Example
// Example of accessing the EyePosition property
PlayerController playerController = new PlayerController();
Vector3 eyePos = playerController.EyePosition;
// Use the eye position for a raycast or other logic
SceneTraceResult traceResult = Scene.Trace.Ray(eyePos, eyePos + playerController.EyeAngles.Forward * 1000).Run();
if (traceResult.Hit)
{
// Do something with the hit object
GameObject hitObject = traceResult.Entity;
// Example: Log the name of the hit object
Log.Info($"Hit object: {hitObject.Name}");
}