I have a simple setup with one Map and one Action, lets say “Jump” with a binding to “Space”.
Now I want to start a charge up animation on “Press” and do the actual jump on “Release” so I a trigger behavior Press And Release
. I added an Subscriber to my Event but I can’t find a way to determine if I am currently in the “Press” or in the “Release” state.
Or should I add two Actions? “Charge” and “Jump”. One with the “Press Only” behavior and the other with “Release Only”
this is what you need to do when choose Press And Release
.
First Add Player Input
component. And then set Player Input
behavior to Invoke Unity Event
.
Add function from your script, let say OnJump
This is logic for press and release button:
//Callback for "Space" button
public void OnJump(InputAction.CallbackContext context)
{
if (context.started)
{
//button is press
}
else if (context.cancelled)
{
//button is released
}
}
You can have a single action (for example “Jump”), and do this:
if (GetButtonDown("Jump")) { //Charge } if (GetButtonUp("Jump")) { //Jump }
Hope this helps!