Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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.