Weird mouse input (with locked cursor)

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!

2 Likes

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:

    CursorLockMode wantedMode;
    // Apply requested cursor state
    void SetCursorState ()
    {
        Cursor.lockState = wantedMode;
        // Hide cursor when locking
        Cursor.visible = (CursorLockMode.Locked != wantedMode);
    }
    void OnGUI ()
    {
        GUILayout.BeginVertical ();
        // Release cursor on escape keypress
        if (Input.GetKeyDown (KeyCode.Escape))
            Cursor.lockState = wantedMode = CursorLockMode.None;
        switch (Cursor.lockState)
        {
        case CursorLockMode.None:
            GUILayout.Label ("Cursor is normal");
            if (GUILayout.Button ("Lock cursor"))
                wantedMode = CursorLockMode.Locked;
            if (GUILayout.Button ("Confine cursor"))
                wantedMode = CursorLockMode.Confined;
            break;
        case CursorLockMode.Confined:
            GUILayout.Label ("Cursor is confined");
            if (GUILayout.Button ("Lock cursor"))
                wantedMode = CursorLockMode.Locked;
            if (GUILayout.Button ("Release cursor"))
                wantedMode = CursorLockMode.None;
            break;
        case CursorLockMode.Locked:
            GUILayout.Label ("Cursor is locked");
            if (GUILayout.Button ("Unlock cursor"))
                wantedMode = CursorLockMode.None;
            if (GUILayout.Button ("Confine cursor"))
                wantedMode = CursorLockMode.Confined;
            break;
        }
        GUILayout.EndVertical ();
        SetCursorState ();
    }

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.

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)

Mouse axis not working - Unity Engine - Unity Discussions mildly related @ end.

1 Like

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.

1 Like

Yep, still having it as well.

Also experiencing this issue.
It works fine in builds and with other analogue input devices.

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

Any news on this? It makes in-editor playback slightly annoying, I’m hoping it gets fixed soon

Still applies in 2016-02-08 build. And it’s such a terrible bug. Hopefully it’ll be fixed in the early-march build.

And since they released a patch minutes after my update, I’ve tested 2016-02-23 and it still applies.

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)

I have the same problem. Any first person camera is completely not functional in editor. Ubuntu 15.10

1 Like

Still present in 5.3.4f1, mouse axis hangs randomly.

…And also in 5.4.0b10

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

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!

1 Like

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.

1 Like

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.

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

I have the same issue on Unity 5.4.0b13

1 Like