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 Action not Getting Triggered on each press

Discussion in 'Input System' started by FlamingVorpalCow, Feb 18, 2020.

  1. FlamingVorpalCow


    Oct 29, 2014
    I'm building a simple platformer game, and was trying to implement the new input system and got a strange issue that the action wouldn't get triggered on every press. Found this issue with the jump action. I tried debugging it, and saw that sometimes the action.triggered wouldn't return true as I pressed my space bar.

    Then I decided to try and see if I would get a different result with the old input system, So I placed 2 Log calls, 1 for the old Input system that says when space is pressed, and one for the new input System (you can see the code on the second image).

    What I found out was that even though the Input was getting handled by the old system, the new one didn't pick it up all the times I pressed.Same happened when using a gamepad to trigger the action.

    What is wrong with this? what am I doing wrong? Or is it some wonkyness on the input system?
    It would be awful, for players to press the button and get 0 response.

    Sin título-1.png Sin título-1.jpg
  2. Jichaels


    Dec 27, 2018
    One of the point of this new input system is that you handle input independently of Update.
    Have a callback for your Jump input, and on performed do your Jump (or any logic)

    EDIT : also, post your input asset here, it could just be wrongly configured
  3. oscarAbraham


    Jan 7, 2013
    Hi, I just saw this. I can help you, I think:

    You don't need to have a callback if you don't want to. You can still do it with polling. The problem is that
    is only true for one frame. Since there are frames where
    is not called, you're missing some button presses.

    There are two solutions: one is to set your boolean variable to true on the Update loop and to false on the FixedUpdate, once you've used it. The second one is to check the inputAction's phase instead of the triggered status. If the phase is either started or performed, and you don't have any weird interactions set on the button, you can know that the button is pressed.

    Let me know if this not clear enough or if you have any other question :) I hope you have a nice day.