Unable to detect both Started and Performed from same action

[UPDATE]: This was user error. I was swapping the action map in the started method so it never had a chance to call performed. Can’t figure out how to delete this post or I would.

I want to do one thing when a button is pressed and an additional thing if it is held. I figured the way to do this would be do the first thing on started and then using a Hold interaction and doing the other thing on performed but everything I’ve tried is telling me it’s only allowed to be one or the other. This can’t be the case which is why I’ve logged this as a bug.

I just swapped over to generating a C# class based on my Input Actions asset and built an input manager around it. In the Input Actions asset my action is set to Hold with the default settings. I’ve tried subscribing to both .started and .performed to the same method and doing a check inside of it:

private void SomeMethod(InputAction.CallbackContext context)
{
  if (context.started)
    //do something

  if (context.performed)
    //do an additional thing
}

This results in the code within the started section running and never hitting performed. If I remove the line where this method is subscribing to started and only leave the one where it subscribes to performed, it calls performed but not started.

So then I tried to break it into two separate methods. Ex: input.started calls one method while input.performed calls another. Exact same thing happens as before—if I’m subscribing to both started and performed, only started gets called. If I comment out the subscription to started, performed will get called. Here’s a code example just for kicks:

private void CalledOnStarted(InputAction.CallbackContext context)
{
  //do something
}

private void CalledOnPerformed(InputAction.CallbackContext context)
{
  //do an additional thing
}

How do you set this up exactly? I’m asking because it is working for me.

I have this in my Awake method (quick test):

            Input = new InputActions();
            Input.SplashScreen.Continue.started += DoContinue;
            Input.SplashScreen.Continue.performed += DoContinue;
            Input.SplashScreen.Continue.canceled += DoContinue;
            Input.SplashScreen.Continue.Enable();

Plus this in the file:

        private static void DoContinue(InputAction.CallbackContext ctx)
        {
            if (ctx.started) Debug.Log("Started");
            if (ctx.performed) Debug.Log("Performed");
            if (ctx.canceled) Debug.Log("Cancelled");
        }

This is the result:
7640197--951769--screenshot.png

And this is the setting:
7640197--951772--screenshot1.png

Input System v1.2.0

1 Like

Omg I’m so sorry—I was swapping the action map inside of the started method… please disregard while I delete this

1 Like