Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Button Input fires multiple times as performed

Discussion in 'Input System' started by x23xSaitama, Sep 2, 2022.

  1. x23xSaitama

    x23xSaitama

    Joined:
    May 12, 2021
    Posts:
    1
    Hey folks,

    as I'm new into the new Input System, this problem is causing me a severe headache:

    When I press a button dedicated to an Input Action, it fires three times (as performed!).


    Here's the script that listens to Input Actions and fire's a Debug.Log
    Code (CSharp):
    1.  
    2.     [SerializeField]
    3.     private PlayerInput playerInput;
    4.     private PlayerControlActions playerControlActions;
    5.  
    6.  
    7.     private void Awake()
    8.     {
    9.         if (playerInput == null)
    10.         {
    11.             playerInput = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerInput>();
    12.         }
    13.  
    14.  
    15.         playerControlActions = new PlayerControlActions();
    16.         playerControlActions.Player.Enable();
    17.    
    18.         playerControlActions.Player.Ability1Charge.performed += OnAbility1Fire;
    19.  
    20.  
    21.     }
    22.  
    23.  
    24.     void OnAbility1Fire(InputAction.CallbackContext context)
    25.     {
    26.         if (context.performed)
    27.         {
    28.             Debug.Log("Ability1Charge: " + context.phase);
    29.         }

    On runtime, when I press the dedicated button (T-Key) ONCE, it gives me this output:



    This is my PlayerInputActions Asset (saved as C#-Asset named "PlayerControlActions"




    The problem does not occur when checking

    Gamepad.current.buttonWest.wasPressedThisFrame
    in
    Update()


    Has anyone seen this happening before?
    I already double-checked if there are any other Player Input Components present in the scene.

    Best regards
     
    Last edited: Sep 2, 2022
  2. GorillaHead7

    GorillaHead7

    Joined:
    Jun 14, 2022
    Posts:
    1
    Did you even Solve this problem? I have a simpler problem where at the start of the input it triggers started and performed once, but when the input is canceled it triggers canceled, started and performed, and then canceled again. I tried setting the trigger behavior to release only, but no luck. Also, the position is not returning the right position in the first started and performed event.