How do I reference use action?

Started by That_Cat_Vivo 3 posts 79 views

Reply on sbox.game
  1. #1
    That_Cat_Vivo
    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. #2
    Omjihn 855
     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. #3
    code 13
    public void OnMouseEvent( MouseEvent e )
    {
        if ( e.LeftMouseButton )
        {
            Log.Info( $"Mouse Down at {e.LocalPosition}" );
        }

        if ( e.IsDoubleClick )
        {
            Log.Info( "Double click!" );
        }
    }