Search Unity

Bug [Fixed in 5.6.0b8] Weird mouse input (with locked cursor)

Discussion in 'Linux Editor' started by LukaKotar, Sep 27, 2015.

  1. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    378
    When the mouse cursor is locked to the center of the screen, (in this case using a mouse look script to rotate the camera) the camera turns around just fine until a certain point, then the view starts jumping around all over the place.

    Setting the Cursor.lockState to CursorLockMode.Locked seems to automatically hide the cursor as well.

    With the cursor unlocked, the camera rotates around as it should (howerver stops when the cursor exits the game view). Once the game is built, it works as it should.

    Edit: Looks like this was fixed in the latest beta build. Thanks!
     
    Last edited: Feb 14, 2017
    pragmascript and Zuntatos like this.
  2. mortalglitch

    mortalglitch

    Joined:
    Aug 26, 2015
    Posts:
    26
    Yeah I have been getting a similar effect.
    I ended up setting up another script thinking it was my code and so I pulled a script from the documentation:
    Code (CSharp):
    1.     CursorLockMode wantedMode;
    2.     // Apply requested cursor state
    3.     void SetCursorState ()
    4.     {
    5.         Cursor.lockState = wantedMode;
    6.         // Hide cursor when locking
    7.         Cursor.visible = (CursorLockMode.Locked != wantedMode);
    8.     }
    9.     void OnGUI ()
    10.     {
    11.         GUILayout.BeginVertical ();
    12.         // Release cursor on escape keypress
    13.         if (Input.GetKeyDown (KeyCode.Escape))
    14.             Cursor.lockState = wantedMode = CursorLockMode.None;
    15.         switch (Cursor.lockState)
    16.         {
    17.         case CursorLockMode.None:
    18.             GUILayout.Label ("Cursor is normal");
    19.             if (GUILayout.Button ("Lock cursor"))
    20.                 wantedMode = CursorLockMode.Locked;
    21.             if (GUILayout.Button ("Confine cursor"))
    22.                 wantedMode = CursorLockMode.Confined;
    23.             break;
    24.         case CursorLockMode.Confined:
    25.             GUILayout.Label ("Cursor is confined");
    26.             if (GUILayout.Button ("Lock cursor"))
    27.                 wantedMode = CursorLockMode.Locked;
    28.             if (GUILayout.Button ("Release cursor"))
    29.                 wantedMode = CursorLockMode.None;
    30.             break;
    31.         case CursorLockMode.Locked:
    32.             GUILayout.Label ("Cursor is locked");
    33.             if (GUILayout.Button ("Unlock cursor"))
    34.                 wantedMode = CursorLockMode.None;
    35.             if (GUILayout.Button ("Confine cursor"))
    36.                 wantedMode = CursorLockMode.Confined;
    37.             break;
    38.         }
    39.         GUILayout.EndVertical ();
    40.         SetCursorState ();
    41.     }
    The code above when "Locked" I can turn normally to the left, but if I turn right I get stuck about half a turn in. Also if I begin to look down I look down about 10% then it jumps the camera to almost looking straight down. When I produce a build though it runs fantastic.

    Also I notice it seems to have different catching points at time I am uncertain though if this is based on testing the game at a different resolution though or not.
     
  3. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    Thank god I'm not the only one. Feels like Mouse.GetAxis 'hangs' sometimes, dumping the old value for 0.1 sec or so. All is well in a build as OP reported. (Sensitivity also seems a lot lower for me, but that's a silly config thing easy to change)

    http://forum.unity3d.com/threads/mouse-axis-not-working.350344/ mildly related @ end.
     
    mortalglitch likes this.
  4. judgementAlex

    judgementAlex

    Joined:
    Sep 9, 2013
    Posts:
    27
    Still having this issue in the latest build (5.2.2f1+20151018). When the cursor is locked, Input.GetAxis and Input.GetAxisRaw return erratic data, resulting in very jumpy first person control. The issue isn't present in the standalone linux player though, only the editor.
     
    Zuntatos likes this.
  5. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    Yep, still having it as well.
     
  6. wllfr

    wllfr

    Joined:
    Jan 27, 2015
    Posts:
    9
    Also experiencing this issue.
    It works fine in builds and with other analogue input devices.
     
  7. judgementAlex

    judgementAlex

    Joined:
    Sep 9, 2013
    Posts:
    27
    Just thought I'd bump this with a video example https://a.pomf.cat/ytrlnn.webm
    this is with slowly moving the mouse up and down - as you can see, there is a large variation in delta values
     
  8. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    378
    Any news on this? It makes in-editor playback slightly annoying, I'm hoping it gets fixed soon
     
    Last edited: Jan 21, 2016
  9. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    Still applies in 2016-02-08 build. And it's such a terrible bug. Hopefully it'll be fixed in the early-march build.
     
  10. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    And since they released a patch minutes after my update, I've tested 2016-02-23 and it still applies.
     
  11. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Well, a somewhat annoying workaround for now would be to have the cursor set to show in the editor until the bug's fixed. Funnily enough, one of the older revisions completely screwed up the analog axis inputs for controllers, making me spin round like an idiot in one spot. (That's been fixed now, or using an Xbox controller did it for me, can't tell which)
     
  12. frizi

    frizi

    Joined:
    Aug 9, 2015
    Posts:
    1
    I have the same problem. Any first person camera is completely not functional in editor. Ubuntu 15.10
     
    Zuntatos likes this.
  13. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    Still present in 5.3.4f1, mouse axis hangs randomly.
     
  14. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    ...And also in 5.4.0b10
     
  15. goditsa8

    goditsa8

    Joined:
    Mar 20, 2016
    Posts:
    1
    Same problem. Weird input with mouse and touchpad. But it seems all works fine with xbox 360 controller.

    ubuntu 14.04.1
    unity 5.4.0b10
     
  16. LeonH

    LeonH

    Joined:
    Oct 15, 2014
    Posts:
    92
    I'm seeing the same issues with mouse axis input in 5.3.4f1 that is described in this thread. This is pretty much a 100% blocker of me being able to use the Linux editor with our company's project day-to-day, as I was hoping to start doing.

    I don't see a Unity rep in this thread yet-- is this actually a known, acknowledged issue? Are forum threads still the best way to report bugs with the Linux editor, as mentioned in the sticky/release topic? EDIT: Ah, I guess that is what the yellow 'BUG' tag next to the topic title indicates. n/m!
     
    Last edited: Mar 31, 2016
    Zuntatos likes this.
  17. judgementAlex

    judgementAlex

    Joined:
    Sep 9, 2013
    Posts:
    27
    Bumping because this is the only bug preventing me from using linux 100% of my workflow.

    Specifically, what's happening is, in the Editor only, the cursor in CursorLockMode.Locked is not actually being locked. If you move around the mouse while locked then unlock the cursor, you can see that it is not centered. When the "locked" cursor is near the edge of the viewport, that's where you see the extreme sensitivity problems seen in my previous post.

    In Linux Player builds, there is no issue since the cursor is properly being centered every frame.
     
    Zuntatos likes this.
  18. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    522
    The 'BUG' tag is something you can add yourself to a new thread, sadly enough. In the previous thread when the bug was more general (it didn't work at all when locked) someone from unity did respond.
     
  19. mapi

    mapi

    Joined:
    Sep 19, 2014
    Posts:
    1
    I have the same issue. Seems like in the editor, when CursorLockMode.Locked is set, the cursor is not locked to the center but acts as a hidden confined mode. When it touches the edges is where the weird axis input starts happening.

    I'm on Ubuntu 14.04.3, Unity 5.4.0b13
     
    Last edited: Apr 16, 2016
  20. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    72
    I have the same issue on Unity 5.4.0b13
     
    Zuntatos likes this.
  21. judgementAlex

    judgementAlex

    Joined:
    Sep 9, 2013
    Posts:
    27
    still present on build 5.4.0b15
     
    Zuntatos likes this.
  22. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    378
    Still happens in 5.4.0p1. Is anyone working on a fix?
     
  23. Tak

    Tak

    Unity Technologies

    Joined:
    Mar 8, 2010
    Posts:
    962
    This is a known issue - the current behavior is a quick workaround for the difference in how the underlying toolkits (player vs. editor) handle mouse grabbing/reporting. If it's really blocking a lot of people, we can increase the priority of a proper fix.
     
    Don-Gray, Sonorpearl, kmare and 2 others like this.
  24. Inaetaru

    Inaetaru

    Joined:
    Aug 9, 2015
    Posts:
    16
    Well, my temporary solution is to define another input axis controlled by keyboard. Accuracy suffers a bit, but it's good enough for me.
     
  25. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    I'm guessing this bug is only for things using mouse controls? I did have some weird input issues a while ago, but all of those got resolved in later builds.
     
  26. ANTR1X

    ANTR1X

    Joined:
    Jan 24, 2013
    Posts:
    2
    Yep... 5.4.0p1 still had this bug. Is any solution to fix this (without remapping axis to keyboard)?
     
  27. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Huh, perhaps the editor isn't taking some oddity with certain mouse drivers into account. I'll see about debugging the editor when I reinstall it. (My Ubuntu partition got wiped a few months ago, still haven't got it back to what it was)
     
  28. Wintero

    Wintero

    Joined:
    Feb 8, 2016
    Posts:
    2
    Bumping this because I'm pretty sure this issue still exists Unity 5.4.1f1, developing a first person game is near impossible without rebuilding to be able to test any new features in order to work around the weird bug.

    @Tak can you give us a status on this bug? It's been known for nearly a year now. :/

    Thanks.
     
  29. mike-mcglumphy

    mike-mcglumphy

    Joined:
    Nov 5, 2015
    Posts:
    1
    I experienced this same issue. Was scratching my head because the FPS Controller in Standard Assets was working just fine, then I suddenly started getting the weird jumpy camera when trying to mouse look. If I hit ESC, the camera would work fine, but then I would get a visible mouse cursor.

    I tracked it down to the PlayMaker Add-On. If you are experiencing this and are using PlayMaker, select the PlayMakerGUI item in the hierarchy and in the Inspector. Then uncheck Control Mouse Cursor in the Play Maker GUI (Script) area.
     
  30. Wintero

    Wintero

    Joined:
    Feb 8, 2016
    Posts:
    2
    Bumping this because I'm still experiencing this issue in the latest build :/ #20160927
    Any news or workarounds?

    Using Ubuntu 16.10 Yakkety Yak with 4.8.0-22 x86_64 kernel.
     
  31. Hoogin

    Hoogin

    Joined:
    Jul 27, 2015
    Posts:
    38
    The bug is still in 5.5.0b5, makes it impossible to use the play mode in the editor if you lock the cursor.
    Have anyone found a workaround?

    Using Slackware 14.2
     
  32. piotr_walkusz

    piotr_walkusz

    Joined:
    Dec 1, 2016
    Posts:
    1
    I found a workaround, but it requires system.windows.forms.dll and system.drawing.dll . You have to add only one script to any of GameObject and (IT'S VERY IMPORTANT) set variable mousePositionInLockedState. This position must be contained in "Game" window (otherwise, camera will go crazy). Now, you must replace Input.GetAxis("MouseX") and Input.GetAxis("MouseY") by MouseManager.GetMouseDelta().

    I attach .unitypackage with ready scene. This is "magic" script :
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Drawing;
    4.  
    5. public class MouseManager : MonoBehaviour
    6. {
    7.     // IMPORTANT !
    8.     // POSITION MUST BE COTAINED IN GAME WINDOW
    9.     // e.g. if you have Game window in left-top corner,
    10.     // set this (100, 100), if Game window is in the middle-top,
    11.     // set this (400, 100)
    12.     public Vector2 mousePositionInLockedState;
    13.  
    14.     public float intensityRate;
    15.  
    16.     private static MouseManager m_singleton;
    17.  
    18.     private Vector2 m_mouseDelta;
    19.  
    20.     private bool m_lastCursorLocked;
    21.  
    22.     void Awake()
    23.     {
    24.         m_singleton = this;
    25.         m_lastCursorLocked = Cursor.lockState == CursorLockMode.Locked;
    26.     }
    27.  
    28.     void Update()
    29.     {
    30.         if (Cursor.lockState == CursorLockMode.Locked) {
    31.             Point mousePos = System.Windows.Forms.Cursor.Position;
    32.  
    33.             m_mouseDelta = new Vector2 (mousePos.X - mousePositionInLockedState.x,
    34.                 mousePositionInLockedState.y - mousePos.Y);
    35.  
    36.             m_mouseDelta *= intensityRate;
    37.  
    38.             System.Windows.Forms.Cursor.Position = new Point ((int)mousePositionInLockedState.x,
    39.                 (int)mousePositionInLockedState.y);
    40.         } else {
    41.             m_mouseDelta.x = Input.GetAxis ("Mouse X");
    42.             m_mouseDelta.y = Input.GetAxis ("Mouse Y");
    43.         }
    44.  
    45.         if ((Cursor.lockState == CursorLockMode.Locked) != m_lastCursorLocked)
    46.         {
    47.             m_lastCursorLocked = Cursor.lockState == CursorLockMode.Locked;
    48.  
    49.             m_mouseDelta = Vector2.zero;
    50.         }
    51.     }
    52.  
    53.     // this replaces Input.GetAxis("Mouse X") and Input.GetAxis("Mouse Y")
    54.     public static Vector2 GetMouseDelta()
    55.     {
    56.         return m_singleton.m_mouseDelta;
    57.     }
    58. }
    I am using Arch Linux x64.

    Sorry for my English.
     

    Attached Files:

  33. Hoogin

    Hoogin

    Joined:
    Jul 27, 2015
    Posts:
    38
    Thanks, I'll try it out. I hope they will resolve this issue soon as it's difficult to develop FPS games.
     
    Zuntatos likes this.
  34. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    378
    Please do so if this hasn't been done yet.
     
    tentaclecatgirl likes this.
  35. markmandel

    markmandel

    Joined:
    Feb 1, 2016
    Posts:
    11
    Thank you! This was driving me nuts too - wasn't sure this was just me.

    I've got a weird rotational bug I can't seem to narrow down, and it only happens when the cursor is locked... and so I can't debug it in the Editor - which is quite frustrating.
     
  36. LukaKotar

    LukaKotar

    Joined:
    Sep 25, 2011
    Posts:
    378
    Might I ask where you got the DLLs from? Was it from a Windows installation of Unity, or some other source?
     
  37. lodendsg

    lodendsg

    Joined:
    Sep 1, 2012
    Posts:
    181
    Is there any word on this?

    Like many our game depends on being able to lock the cursor to the centre of the screen and hide the cursor yet for the various pointer events to still fire as we use raycasters and IPointer interfaces for most of our interactions.

    I have been browsing around a lot and get a mixed feeling .. what is Unity's intended behaviour with this? documentation says Cursor.lockState = CursorLockMode.Locked; will lock the cursor to the centre of the screen ... in our case its locking it to -1,-1

    Does locking and hiding suppress some or all pointer events?
    In our testing its suppressing mouse enter and exit but not click e.g. with pointer locked to -1,-1 (lower left corner) we can move the camera such that an intractable is in the lower left corner of the screen and the click event does fire but the enter and exit events do not.

    Using windows dll isn't an alternative we can use, so assuming this is intended behaviour or a bug not due to be fixed anytime soon its looking like our only option is to replace the functionality of Unity's cursor, event system and input module which is not going to fly well.

    Its worth noting that this did work under an older version of the engine ... so I am hoping this is simply and introduced bug.
     
  38. Duobix

    Duobix

    Joined:
    Dec 6, 2014
    Posts:
    47
    Just have running my project on 5.6.0xb3 / Linux Mint 18.1,
    The cursor behaves in a strange manner as reported, BUT, when I did
    build the solution for linux (86_64) it also didn't work.
     
  39. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    303
    Yeah.. that weird. Spent hours to understand that it's not my code trouble but some engine issue. Using Mac, 5.5.0p3.
    Will be there some fixes soon?
     
  40. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Macs don't count buddy... unless it's running Linux, then it counts.
    This is a Linux Editor bug.
     
  41. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    303
    Not sure what did you mean here, but I got same buggy behaviour in mac editor version
     
  42. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Is it happening on Macs too? Sorry if it is, this thread was started for the Linux Editor, so I thought it went off-topic to mention macs in here.
     
  43. JeremyCooper

    JeremyCooper

    Joined:
    Mar 15, 2017
    Posts:
    1
    Any update? Same issue with playback in the Linux editor.
     
  44. adrianmarino

    adrianmarino

    Joined:
    Jan 4, 2016
    Posts:
    1
    I solved it downgrading to 5.5.2xf1 version(under arch linux), but 5.5.2xf1 has less performance than 5.6.0xb10 (Linux Releases).
     
    Last edited: Mar 26, 2017
  45. PferdImAnzug

    PferdImAnzug

    Joined:
    Jul 26, 2013
    Posts:
    11
    I just tried 5.6.0f1 and the bug is fixed. This is very huge for me, as this was the one issue which was really blocking me from using Linux Editor 'seriously'. Thank you for fixing that!
     
  46. smessimer

    smessimer

    Joined:
    Sep 4, 2017
    Posts:
    1
    I'm getting this same issue in 2017.1.1. Anybody else?
     
    Sonorpearl likes this.
  47. Sonorpearl

    Sonorpearl

    Joined:
    Sep 8, 2017
    Posts:
    32
    Got the same problem on the newest Version 2017.1.1.f1

    The Input Axis for the Mouse just randomly starts to change and hang up for a little bit.

    Mouse Y-Axis 0.1 Mouse X-Axis -0.85 Time: 0.004562002
    Mouse Y-Axis -0.4 Mouse X-Axis -35.85 Time: 0.1851212

    Edit: I get it in the Windows Editor.
     
    Last edited: Sep 24, 2017
  48. mightysky

    mightysky

    Joined:
    Aug 13, 2018
    Posts:
    1
    Go this in 2018.3.10 and 2018.3.12f1. Linux 64 bit. <OpenGL 4.5>

    OS: Fedora release 28 (Twenty Eight) 64-bit
    CPU: Intel® Core™ i5-8250U CPU @ 1.60GHz × 8
    Graphics: Intel® UHD Graphics 620 (Kabylake GT2)
    GNOME: 3.28.2

    Mouse delta goes crazy. Looking into logs seams the the sign of delta goes crasy.

    //////////////////////
    Code to test:

    private void Awake()
    {
    Cursor.lockState = CursorLockMode.Locked;
    }

    private void Update()
    {
    if (Cursor.lockState == CursorLockMode.Locked)
    {
    var lookRotation = Input.GetAxisRaw("Mouse X");
    Debug.Log($"Input.GetAxisRaw(\"Mouse X\"): {lookRotation}");
    }
    }
    //////////////////////
     

    Attached Files:

  49. grobonom

    grobonom

    Joined:
    Jun 23, 2018
    Posts:
    116
    I reporteg the bug with a linked project on this some months ago, and have been answered that U3D team reproduced the bug.

    but since then, no news at all. It appears to impact all people locking and hiding the mouse.
    Any news on this or will unity definetely give up on this bug that prevents users to target linux when hiding mouse ?
    :/