mmm thx Lurking-Ninja, but it’s not quite what I’m looking for:
CallBackContext.duration reports 0 when no Hold is set in the Interaction panel.
The Hold Interaction seems to be mandatory for timers to start from.
duration appears to be directly linked to Hold.time setting in the Interaction panel.
It may serve my initial objetive for simple holding events, but if I’d ever wanted to feature a variable height Jump mechanic (mostly 2D platformers), the character should always jump, no matter how much time I’m pressing the button.
The amount of force applied for the jump is what (I think) will be modified by CallBackContext.performed. For single values it’s fine, but I may end having to stack multiple Hold Interactions…
Yes, there is no meaning of a timer when you have immediate controls. When the performed event and the started event are firing at the same time, duration is obviously zero. It wouldn’t make sense any other way. If you need custom behavior, you will need to develop it. It’s not too complex, just record the CallbackContext.time in the start event and record whenever you feel you have to fire an event and subtract the recorded time from the latest CallbackContext.time and you get a duration (in cancelled event for example).
If you’re custom pooling you can do it with Time.realtimeSinceStartup or something.