I have a button action called “Fire”, bound to the Right Trigger.
I added a “Press” interaction to the Right Trigger binding under it, and chose “Press and Release” as the behavior.
Then, based on the instructions in the tooltip, I set up my code like this:
My idea being that when I release the trigger, it should call the StopFiring() method.
However, the “StopFiring” method seems to not be called at all, as the “Firing” boolean stays true and the Debug.Log is never printed to the screen.
I too am looking forward to this feature of Unity, but somehow, I couldn’t get it to work either… This is what I do temporarily though… I created 2 Actions solely for a ButtonDown and a ButtonUp, I hope this gets resolved soon as well
AFAIK, the ReadValue gets called only when the button is pressed (and when the button is released if that was enabled in the setting)… Now I think what we want is something like a charge function, where the ButtonDown would initiate the charge and the ButtonUp releases the charge… The problem is that wouldn’t some god-forsaken lag cause the controls to reverse their functions? Like once you initiate a charge, a lag spike occurs, as that happens you release the button, wouldn’t there be a chance that the ButtonUp event won’t register? If that happens, wouldn’t the next ButtonDown release the charge, and the next ButtonUp initiate the charge? This scenario would lead us wanting ButtonDown to have an exclusive function (initiate charge), as well as for ButtonUp (release the charge).
I’m not sure if I’m doing this right since I dove into it just recently, but I’ve never had the ReadValue go to anything other than “0”… I tried it both on Update and FixedUpdate but it never registered as “1”… Same goes for the phase, it just states “Waiting”… Canceled doesn’t seem to work either, from what I understand it only works with something like using Hold, and triggers when released prematurely… It shouldn’t work on Press since the press occurs once and immediately, and doesn’t have a fail-check?
Closest thing I can think of is to use Hold, set the Hold Time to “infinite” and wait for the “canceled” event to occur…
I’m probably missing a point somewhere…
EDIT: Just found out that having absolutely NO INTERACTIONS in the settings solved the problem of not detecting the “canceled” event…
DevBaro & Elledivar, y’all saved my life! I’ve spent hours today trying to figure this out (is this just a bug?) and clearing the Interactions just did it for me. I hope they fix/clarify this later in the documentation, because it sure is a lot more complicated than just using Input.GetButton (although in the long run it saves you a ton of time).
So with the interaction set to “Press and Release”, checking with .performed and .cancelled on f.e. Right Mouse button, I got this log:
Action pressed
Action pressed
Action released
Notice there is an extraneous “pressed” phase in there that completely screwed me over for the past 1.5 hours.
Following this thread’s suggestion made in big red letters, removing the interaction setting, I get this log:
Action pressed
Action released
… meaning that this is definitely bugged on 2022.3.6f1.
Well, actually, I am guessing that this is the intended behavior and that both someone misunderstood the concept of a “canceled” input AND someone else forgot to update the documentation and tooltip.