Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: BlueSin on March 07, 2016, 01:39:07 AM

Title: Mouse cursor resetting to center screen on move?
Post by: BlueSin on March 07, 2016, 01:39:07 AM
I am implementing WASD movement across my 2D tile maps using the built in Horizontal and Vertical axes in Unity.  When I start pressing those keys though the mouse cursor jumps back to the center of the screen, if I try to move the mouse cursor around while using WASD the cursor just keeps resetting to the center of the screen every few frames.  I know this is caused by NGUI because if I disable the UIRoot object in my scene it stops doing it.  Traversing the map works fine, it is just annoying that the cursor jumps to the center of the screen, and will be problematic later given the way I intend to design my game.

Is there a setting somewhere to change this behavior?
Title: Re: Mouse cursor resetting to center screen on move?
Post by: devomage on March 07, 2016, 06:29:28 AM
1.  Find your GUI Camera and toggle "Auto Hide Cursor" in the inspector.

2.  Try commenting out anything that has to do with "Screen" or "Cursor" class within UICamera (around line #545).

3.  This thread randomly appears often!  A thorn rather than a bug...  very annoying indeed.
Title: Re: Mouse cursor resetting to center screen on move?
Post by: Dune on October 21, 2016, 04:15:45 AM
I tried this, but then my OnClick events stopped working.
Title: Re: Mouse cursor resetting to center screen on move?
Post by: ArenMook on October 24, 2016, 06:49:28 AM
UICamera.autoHideCursor is all that's needed to be turned off (and as devomage pointed out it can be done via inspector). There is no need to edit code.
Title: Re: Mouse cursor resetting to center screen on move?
Post by: Dune on October 28, 2016, 01:34:54 AM
With "Auto Hide Cursor" on or off, pressing any movement (WASD) and the cursor appears / disappears for no apparent reason. Making movement jerky. And the cursor is warped to the center of the screen.

Any ideas to what could be causing it?

I've disabled my player controller, to be sure it isn't my code.
Title: Re: Mouse cursor resetting to center screen on move?
Post by: ArenMook on October 30, 2016, 12:16:23 PM
Turn off your controller input on the UICamera. I'm guessing you have some movement axes bound to WASD which are also specified on the UICamera as navigation axes.
Title: Re: Mouse cursor resetting to center screen on move?
Post by: Shifty Geezer on July 08, 2017, 11:22:36 AM
I'm experiencing the same issue using mouse game. Only using the mouse for input (emulating touches - the game is aimed at touch screens), sometimes when playing in the editor the mouse decides to keep being centred at fractional second intervals; it's not every frame judging by the distance the pointer moves. I had it just now where it kept doing this every run, and restarted Unity where the problem was fixed (other than the sporadic issue always faced). I have a PS3 controller attached via USB which might be involved? I'm guessing it's something like that because restarting Unity eased the problem, but it's not consistent.

Next time I'll try disabling the controller in UI camera. However they should be able to operate side-by-side.
Title: Re: Mouse cursor resetting to center screen on move?
Post by: ArenMook on July 15, 2017, 06:02:30 AM
They do operate side by side, but activating one hides the other -- otherwise you would have two things selected at the same time (hovering mouse + controller-selected object). Sounds like your controller was reporting non-zero values that were caught by the UICamera because the axes used were specified on it. This can also be resolved by increasing the dead zone of your controller input.