Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Input Manager Creating False Inputs in Editor

Discussion in 'Editor & General Support' started by noscope420, Nov 24, 2023.

  1. noscope420


    May 17, 2017
    I am using the old input system. Whenever I play my game in the editor, and I press Sprint and Jump at the same time, 2 of my other button inputs are fired (Menu and Cancel). This only happens in the editor. The consequences of this are that the game gets paused when sprinting and jumping at the same time in the editor, and when the game is unpaused, the Sprint and Jump buttons will be stuck in the pressed state. I couldn't upload a video, so I uploaded it to my website and linked it instead. Edit: I am using Unity 2022.3.8f1

  2. CodeSmile


    Apr 10, 2014
    please post your input code
  3. Kurt-Dekker


    Mar 16, 2013
  4. noscope420


    May 17, 2017
    I don't believe it is keyboard rollover, as this does not happen when I build the game and run it outside of the editor. Please see the video I attached, as my script already prints lines to the console when the buttons in question are pressed, this was the first thing I did to try and troubleshoot. I also used this keyboard rollover tester

    I have attached the script that checks these inputs to this post. The entire project is available here.

    Attached Files:

  5. Kurt-Dekker


    Mar 16, 2013
    So from those Debug.Log() statements, is the "Menu" axis firing when it shouldn't?

    If so then it is an input setup problem: fix it in the input manager or else delete the Menu entry and remake it correctly.

    Otherwise it sounds like maybe it's just a bug, which can only mean...

    Time to start debugging!

    By debugging you can find out exactly what your program is doing so you can fix it.

    Here is how you can begin your exciting new debugging adventures:

    You must find a way to get the information you need in order to reason about what the problem is.

    Once you understand what the problem is, you may begin to reason about a solution to the problem.

    What is often happening in these cases is one of the following:

    - the code you think is executing is not actually executing at all
    - the code is executing far EARLIER or LATER than you think
    - the code is executing far LESS OFTEN than you think
    - the code is executing far MORE OFTEN than you think
    - the code is executing on another GameObject than you think it is
    - you're getting an error or warning and you haven't noticed it in the console window

    To help gain more insight into your problem, I recommend liberally sprinkling
    statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run? what order does it run in?
    - what are the names of the GameObjects or Components involved?
    - what are the values of the variables involved? Are they initialized? Are the values reasonable?
    - are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

    Knowing this information will help you reason about the behavior you are seeing.

    You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as

    If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

    You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

    You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

    You could also just display various important quantities in UI Text elements to watch them change as you play the game.

    Visit Google for how to see console output from builds. If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer for iOS: or this answer for Android:

    If you are working in VR, it might be useful to make your on onscreen log output, or integrate one from the asset store, so you can see what is happening as you operate your software.

    Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

    If your problem is with OnCollision-type functions, print the name of what is passed in!

    Here's an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

    If you are looking for how to attach an actual debugger to Unity:

    "When in doubt, print it out!(tm)" - Kurt Dekker (and many others)

    Note: the
    function is an alias for Debug.Log() provided by the MonoBehaviour class.
  6. noscope420


    May 17, 2017
    So I went ahead and set up a new project with the same unity version. I copied only the four inputs in question from the old project, to the new one. I made a simple script that prints when that input is fired. That is all this project consists of, no other variables.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    5. public class KeyboardTest : MonoBehaviour
    6. {
    7.     // Start is called before the first frame update
    8.     void Start()
    9.     {
    11.     }
    13.     // Update is called once per frame
    14.     void Update()
    15.     {
    16.         if(Input.GetButtonDown("Sprint"))
    17.         {
    18.             print("Sprint Button Pressed");
    19.         }
    20.         if(Input.GetButtonDown("Jump"))
    21.         {
    22.             print("Jump Button Pressed");
    23.         }
    24.         if(Input.GetButtonDown("Menu"))
    25.         {
    26.             print("Menu Button Pressed");
    27.         }
    28.         if(Input.GetButtonDown("Cancel"))
    29.         {
    30.             print("Cancel Button Pressed");
    31.         }
    32.     }
    33. }
    When I run this, and press "Sprint" and "Jump" at the same time, "Menu" and "Cancel" are also fired. I tried this again with the Alt. Positive fields blank, and got the same result. This seems to be a bug in the editor. I tried it with another keyboard as well, same result. I am doing this on Manjaro Linux but I will try it on Windows 10 to see if I get the same result again, and edit this post to add my results.

    In this screenshot, I did the following test:
    1. Pressed "Sprint", let go immediately, and waited at least one second
    2. Pressed "Jump", let go immediately, and waited at least one second
    3. Pressed "Jump" and "Sprint" simultaneously, and let go immediately
    When I executed Item 3 at 13:09:48, GetButtonDown() for "Sprint" fired twice, then "Jump", then "Menu", then "Cancel". This is consistent across multiple tests with different keyboards.

    For my next test I did the following:
    1. Changed "Sprint" from left shift to a, changed "Jump" from space to s, an performed steps 1 through 3 from the above test.
    2. Left "Sprint" as left shift, changed "Jump" from space to s, an performed steps 1 through 3 from the above test.
    3. Left "Jump" as space, changed "Sprint" from space to a, an performed steps 1 through 3 from the above test.
    The results were:

    1. When pressed at the same time, both inputs would fire correctly.
    2. When pressed at the same time, only "Sprint" would fire.
    3. When pressed at the same time, both inputs would fire correctly.
    It would seem that left shift does not play nicely when other keys are being pressed at the same time, especially space for some reason. If anyone else would like to try, you can just copy that code into a script and attach it to an empty game object within a scene.
    Last edited: Nov 27, 2023
  7. noscope420


    May 17, 2017
    I've gone ahead and created a bug report for this here. If anyone else has tested this with the script I provided, please share your results. I did some research and found a couple instances of the Shift key blocking input in the Linux editor, as far back as two years ago. Example 2 has a comment from another user explaining that it only happens in editor. All users report they were using Linux. Seems like the Linux editor has had this bug for quite some time.