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. Dismiss Notice

Question New Input System: new set buttons not resetting on release

Discussion in 'Input System' started by l3m35, Aug 29, 2021.

  1. l3m35

    l3m35

    Joined:
    Apr 1, 2019
    Posts:
    5
    I'm using the Starter Assets - Third Person Character Controller, and added some new buttons over the new input system: Interact and Skip (this one in another map, so I can alternate when player comes closer to a NPC and press interaction button).

    I followed the same pattern of the (pre-configured) Jump button.



    When I test it, the Jump button is OK: I press it, bool true; I release it, bool false.

    But when I press my new buttons, the input is always marked, even after the button or key is released (bool always true). Tested on keyboard and controller.



    The code on StarterAssetsInput.cs is this (edited the Jump function):

    Code (CSharp):
    1.  
    2.         public bool interact;
    3.         public bool skip;
    Code (CSharp):
    1.  
    2.         public void OnInteract(InputValue value)
    3.         {
    4.             InteractInput(value.isPressed);
    5.         }
    6.         public void OnSkip(InputValue value)
    7.         {
    8.             SkipInput(value.isPressed);
    9.         }
    Code (CSharp):
    1. public void InteractInput(bool newInteractState)
    2.         {
    3.             interact = newInteractState;
    4.         }
    5.  
    6.         public void SkipInput(bool newSkipState)
    7.         {
    8.             skip = newSkipState;
    9.         }

    Any idea? Am I forgetting or ignoring other configuration?
    Thank you.
     
  2. mmhouston6

    mmhouston6

    Joined:
    Aug 13, 2018
    Posts:
    2
    Same issue, tried in another script and same thing. I also tried on Input System version 1.3.0 and 1.0.2. Have you found a solution?
     
  3. adlar

    adlar

    Joined:
    May 9, 2019
    Posts:
    1
    Bumping this, I'm having this problem right now and can't find a fix for it
     
  4. polluxik

    polluxik

    Joined:
    Aug 17, 2017
    Posts:
    11
    I had same problem but when I looked into code I found that
    _input.jump = false;
    in
    private void JumpAndGravity() { }
    makes jump variable to be false because of this line of code...
    If you want to know when the button was performed or canceled... I recommend using C# events... It will give you these callbacks...
    check this: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.4/manual/Actions.html
    I hope this will help ;)
     
  5. haker23

    haker23

    Joined:
    Dec 2, 2017
    Posts:
    1
    In case it helps someone - I experienced an infinite jumping bug because "jump" state was not resetting after releasing space key.

    SOLVED!

    As polluxik said - the solution was looking at JumpAndGravity (which lead me to GroundedCheck)

    I had recently changed the player gameobject's layer to Default (because the originally-assigned-layer was unnamed in my project settings) but this actually broke the ground check.

    After my change, it always detected something (the player) when checking for ground during a jump, so it never reset the jump state to "false" :oops:

    Lots of ways around it - I decided to move the player to a new layer called "Player" so it cannot interfere with the ground check.