Search Unity

Bug Mouse pointer erratic behaviour

Discussion in 'Open Projects' started by drbier, Nov 30, 2020.

  1. drbier

    drbier

    Joined:
    Oct 4, 2020
    Posts:
    10
    cirocontinisio likes this.
  2. drbier

    drbier

    Joined:
    Oct 4, 2020
    Posts:
    10
    Found something, but not sure if it is related to this particular bug or if it is closer to this one [Input is cached when not immediately consumed by a State]:

    When rotating the camera using TFGH, if I left click the mouse, the camera will sometimes orbit the character at full speed automatically even when I let go of all buttons and the mouse. The orbit ends if I right click.
     
  3. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Hey @drbier, sorry for the poor description, and I realised the video wasn't showing the issue - really. I updated it with a new video. And I created the issue on Github etc. So feel free to give it a shot!

    And in fact, I realised why the issue happens while filming the video. But I'm not going to tell you! :) You find it yourself.
    I'll give you a clue though: follow the cursor closely!
     
    davejrodriguez likes this.
  4. drbier

    drbier

    Joined:
    Oct 4, 2020
    Posts:
    10
  5. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Hey @drbier, somebody already produced a PR with a fix... which I think is the right one. If you want to still try to fix it (almost as a challenge to yourself) go on, and don't read the PR :D
    If instead you want to take the fast route or just want to see how they did it, here it is.
     
  6. drbier

    drbier

    Joined:
    Oct 4, 2020
    Posts:
    10
    Cool no worries. I wasn't able to reproduce it anyway. My idea was to use a coroutine to wait a frame after the mouse control is enabled to skip the initial mouse delta spike... I saw that someone who was able to replicate the bug suggested that on Github already. I'll find something else to do one of these days!
     
    cirocontinisio likes this.
  7. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Yes, the issue is that since the cursor is "locked" when pressing the RMB, it is teleported to the centre of the screen (and kept there, I think?). This means that on the first frame, depending how close to the centre you press, you're going to see a huge X value in the input especially if your window is quite wide.

    I'll merge that fix then!
     
    gigamochi likes this.