How do you do the equivalent for GetButtonDown, GetButton, and GetButtonUp in an Update method using an InputAction?
According to the current “How Do I” section of the docs, in the fireAction example, an InputAction has a hasBeenPerformedThisFrame, but I’m not able to access it. Has this been removed?
When using events, all the examples show event subscription using lambdas, and enabling and disabling actions. I’m assuming we need to unsubscribe also, or is that not needed when using lambdas?
Did a lot more testing, forum searches, etc. Hope someone can correct me if the following is wrong:
According to this post , to get the equivalent functionality of the GetButton methods of the old input system, leave “interactions” blank, and check “continuous” for the InputAction. This will have “started” and “performed” events fired on pressing the button (the equivalent of GetButtonDown), “performed” fired as long as the button is held down (GetButton), and “canceled” fired when the button is released (GetButtonUp).
There is no equivalent to a bool for started, performed, or canceled on the InputAction which simply lets us do a check like:
if (Input.GetButton(“SomeButton”)
{
// Code here.
}
like in the old system. We currently have to have another layer of abstraction by assigning bools when handling the events, and setting these bools to false every frame after the logic is done. This extra work should be unnecessary, but I guess with all the different types of interactions on the InputAction that can fire the started/performed/canceled events at different times, perhaps this makes sense? It’s a little convoluted.
As mentioned above, seems like these bools have been removed, adding another layer of complexity.
Edit: My original answer was wrong. It’s difficult to unsubscribe from an anonymous method, and thus we’d need a reference. It’s safer to just subscribe/unsubscribe to a regular method. Enable()/Disable() has nothing to do with event subscription I believe.