Description
The Pressed
property of the PlayerController
class represents the component that the player is currently interacting with by holding down the "USE" button. This property is useful for determining which object the player is actively using or manipulating in the game environment.
Usage
To access the Pressed
property, you can use the following syntax:
PlayerController playerController = new PlayerController();
Sandbox.Component currentPressedComponent = playerController.Pressed;
This will give you the component that the player is currently using. If the player is not using any component, this property will be null
.
Example
PlayerController playerController = new PlayerController();
// Check if the player is currently using an object
if (playerController.Pressed != null)
{
// Perform actions with the pressed component
Sandbox.Component usedComponent = playerController.Pressed;
// Example: Log the name of the component
string componentName = usedComponent.Name;
// Perform further actions with the component
}
else
{
// No component is currently being used
}