Actions Left Mouse Button DOWN notification

Hi,

I’ve set up an action called ‘Fire’ for the left mouse button, but when I log the event callback, I get three messages instead of one. I suppose it’s because I get down, hold and up events.

How do I specify to get only the down for instance ?

Thanks,

Actually, what you’re getting is probably started, performed, and canceled events.

There is multiple ways you can do that :

  1. On your action, add a press interaction set to Press only

  2. On your callback, use this :

public void YourCallBack(CallbackContext ctx)
{
    if(!ctx.performed) return;

    // your logic
}

yep, thanks,

I ended using ReadValue function.

What I didn’t get is that I need to generate the c# class from the actions to then access everything.

TY

You don’t NEED to, you can. You can either use the PlayerInput component, and bind your callbacks in here. You can use InputActionReferences, or you can use the generated C#. It all depends to you / what you prefer