Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug ReadValueAsButton() not working properly in build

Discussion in 'Input System' started by OriolSC, Jun 3, 2021.

  1. OriolSC

    OriolSC

    Joined:
    Oct 7, 2019
    Posts:
    9
    I believe I have found a bug where the function ReadValueAsButton() is not working as expected in a build where the function in question, either does not update or read the value of the button properly.

    I did not see this bug reported and this makes me quite surprised. It is a major problem that can easily break a game completely. For example in my case, once the players jumps, it gets stuck in an infinite jumping loop. In the Unity editor, everything works perfectly. It is only an issue that appears in the build.

    In my game, I have a very simple function to detect if the jump key/button has been pressed.
    upload_2021-6-3_21-11-9.png

    And here two screenshots. The first one of the Unity Editor and the second one of the build.
    upload_2021-6-3_21-17-24.png upload_2021-6-3_21-17-40.png

    When performing a jump, the manager function gets called two times. When pressed and when released.

    When the jumping button has been pressed, ReadAsValueButton() gives a value of True (correct behaviour) while ReadValue<>() returns a value of 1 (correct behaviour). Both Unity Editor and build works fine here.

    The problem appears when the jumping button has been released. Here, ReadAsValueButton() returns False on the Unity Editor (correct behaviour) but in the build, it returns True (wrong behaviour). ReadValue<>() works properly in both cases, so it is an alternative solution.