One thing I did with my action map is to allow both Mouse and Keyboard input to trigger the same Action, for example, Camera Zooming.
But now I realize Mouse Scroll and Keyboard Button Press behaves quite differently, and really we need to handle them differently, even though logically they are the same Action.
I wonder what Unity recommend here? Just create another Action to handle Mouse Scroll specifically? Or Can we identify which Binding fired in an Action event?
(I am using Input system with Unity Event, so all I get is a CallbackContext, which doesn’t seem to have any property about bindings.)
You can use the control property. This one isn’t really intuitive without the documentation, but there is a reason why they call it control (what you can find out if you read the InputControl page).
Do you do discrete action on scroll or something continuous? If you’re scrolling for example, when the event comes from the mouse scroll (use control property for identification) you can multiply the amount of scrolling with time.deltaTime so it becomes frame rate-independent.
If you do discrete action though (like switch weapon on scroll for example, or similar), you don’t really have any other choice but to detect when the last activation happened and only execute the next one if some time elapsed. Or you can switch the scroll to vector2 input and check the delta and do the change when the delta is big enough.
I don’t really understand the reason why don’t you define these as an Axis? I’m guessing you have two buttons and you have the Mouse Scroll Y. Both can behave like an Axis. So it would give you a “continuous” behavior. Just an idea.
Zoom: action type: Value control type: Axis
Scroll/Y binding is just the mouse scroll Y binding
KeyboardZoom binding is 1D Axis composite with positive and negative