How do I reference use action?

Started by That_Cat_Vivo · 4 months ago · 2 replies · 79 views

#1
That_Cat_Vivo
Member
JoinedMar 2025 Posts1 Score0
I'm a new dev and have mostly worked with Unity before now. I'm trying to make my first project in S&Box but the API ref hasn't been extremely clear to me.

I want to reference the "use" player actions results, but I don't know how exactly to input the "PlayerController.IEvents" the API talks about.

I'm specifically trying to set up a way to detect when the player is facing an "NPC" object, so I can then open a dialogue box.

Any advice would be appreciated.
#2
Omjihn
Member
JoinedMar 2026 Posts20 Score855
 Hi !

If I where you I would check this : https://github.com/Facepunch/sandbox/tree/main/Code/Items/Pickups
It is the pickup logic of the Sandbox Game made by Facepunch.
Since it is open source you can download and open it in the editor to understand how it works.

enjoy! 
#3
code
Member
JoinedMay 2026 Posts19 Score13
s&box API Reference
MouseEvent - s&box API Reference
Information about a Widgets mouse event.
public void OnMouseEvent( MouseEvent e )
{
    if ( e.LeftMouseButton )
    {
        Log.Info( $"Mouse Down at {e.LocalPosition}" );
    }

    if ( e.IsDoubleClick )
    {
        Log.Info( "Double click!" );
    }
}
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.