Search Unity

Input.MouseButtonUp(0) sometimes not detected in Update() method

Discussion in 'Input System' started by Zacheraay, Nov 13, 2021.

  1. Zacheraay

    Zacheraay

    Joined:
    May 29, 2021
    Posts:
    1
    I have a simple shoot script that is called from a recorded input in the Update() method. I initially used if(Input.GetMouseButton(0)) as it is perfect for what I want, however, I noticed that sometimes, specifically when I click the mouse button several times fast, and in the end not be holding down the mouse, Input.GetMouseButton(0) will still return true. I wrote my own script that would perform the same task as Input.GetMouseButton(0) using mouseUp and mouseDown, however, the same problem persisted because Input.GetMouseButtonUp(0) would sometimes not return true when performing the same test. I would have thought this is because even Update() cannot always capture every input recorded, however, I am more confused at the fact that Input.GetMouseButtonDown(0) never fails. Any help would be greatly appreciated!
     
  2. momoguru

    momoguru

    Joined:
    Mar 9, 2014
    Posts:
    11
    having the same issue here with 2021.2.0f1
    the Input.GetMouseButton(0) is getting stuck to TRUE if i double click just right. driving me crazy.
     
  3. cheeze_12

    cheeze_12

    Joined:
    Aug 25, 2017
    Posts:
    3
    I'm having the same issue. Seems to only happen on left mouseclick. I'm on 2021.2.2f1
     
  4. adslitw

    adslitw

    Joined:
    Aug 23, 2012
    Posts:
    275
    @Zacheraay @momoguru @cheeze_12 what OS etc are you all on? I’ve got what I think must be the same issue, but with keyboard input (I don’t use mouse in my game). I’m on Mac OS Monterey, M1 Pro.
     
  5. adslitw

    adslitw

    Joined:
    Aug 23, 2012
    Posts:
    275
    @Rene-Damm or @dmytro_at_unity is there any info on this? Is it on your radar, do you know what's going on, have you replicated it? Etc etc. I submitted a bug report a couple of weeks ago which I haven't had a response for yet (#1381681) - it would be really good to get some confirmation that it is, at the very least, something you're aware of. Just a quick response to one of the several threads on here would be great. Thanks.
     
  6. liamkwt

    liamkwt

    Joined:
    Mar 11, 2020
    Posts:
    1
    Also having this issue. Will report if I can find a fix.
    If anyone wants to try to replicate it. The second debug is ignore from time to time on fast sequential clicks. Right click works perfectly fine...
    Code ran from update:

    void boostConditions()
    {
    if (Input.GetMouseButtonDown(1))
    {
    initiatedBoost = true; //this is so you can't just hold boost 24/7
    Debug.Log("MOUSE DOWN PRESS");
    }
    if (Input.GetMouseButtonUp(1))
    {
    if (initiatedBoost)
    {
    initiatedBoost = false;
    }
    Debug.Log("MOUSE UP RELEASE");
    }
    }