4.7 Lock mouse to viewport problem

Hi,

The mouse lock seems to disappear after any mouse button is clicked. To reproduce:

  1. Create a new project based on the top-down example.
  2. In the TopDownController-blueprint, hook a “Set Input mode Game and UI”-node to the Begin Play-event and check “Lock mouse to Viewport” with a reference to self as the target.
  3. Play in editor

The mouse is properly locked to the viewport until a mouse button is clicked, which removes the lock. A fun observation is that it works if we turn the default cursor to “none”, leaving us with proper locking but no cursor. I’m fairly sure this isn’t working as intended (it worked in 4.6), though if it is how can I force the cursor to stay locked to the viewport?

Cheers,

Isvulfe

Hello Isvulfe,

Thank you for informing us about the lock mouse feature within ‘Set Input mode Game and UI’ not working correctly for you. For clarification, when you are dragging the mouse during play in editor, is your mouse going out of bounds when you click and hold to walk the character around, or is it not staying in the viewport at all?

Detailed reproduction steps would be extremely beneficial for us to assist you with this issue, any additional information would be greatly appreciated.

Thank you!

Hi Samantha,

After I first start play in editor (either via the button or using the ALT+P hotkey), the mouse is locked to the viewport. It stays locked until any mouse button is clicked (left, right, middle). The simplest way I’ve found to reproduce the issue is:

  1. Open the UE-launcher
  2. Launch 4.7.1
  3. Create a new project (File->New project)
  4. Choose the Top Down project and click “Create project”
  5. In the new project open the TopDownController-blueprint.
  6. Add this to the blueprint:

31690-blueprint_input.png

  1. Compile and save the blueprint.
  2. Click Play

The mouse is now locked to the viewport. Whenever a mouse button has been clicked (the click is released) the lock is removed and I may move the cursor outside the viewport. While a mouse button is being pressed, it is however locked to the viewport. The issue is not only present while playing in editor, but also while playing in a standalone window.
If I open the TopDownController again and open the Class Defaults and set the “Default Mouse Cursor” to None, the issue is “resolved”, meaning that the mouse stays locked within the viewport, though I have no mouse cursor.
Hope that clears it up.

Cheers,
Isvulfe

Hello Isvulfe,

Thank you for providing me with the exact steps you’re taking. I have successfully been able to reproduce this issue in 4.6.1 as well as 4.7.1. This is definitely an issue that has since been reported to our developers. UE-7293 is the number you can reference if you’d like an update in the future. At this time, it’s still currently being worked on however, it should be corrected in a future update.

Thank you again for your report.

This issues is still unresolved in version 4.8. Is there any anticipation to getting this resolved? As the OP mentioned, this is an undesirable action. The only hack/workaround that I can see is to lock the cursor in each node group that uses a mouse action or to put it into ‘Event Tick’ which both cases are undesirable and should be unnecessary. Thanks.

Hey JT,

UE-7293 has not been resolved yet. It’s currently set as a major issue for 4.9. Unfortunately, I do not have the estimated timeframe on when this will be implemented but you’re more than welcome to check in after each update and I’ll provide you the information available.

Thank you and have a wonderful day! :slight_smile:

Just want to say I have the same problem and it’s not fixed in 4.8.1 unfortunately…

I am having a similar problem. I’m trying to set up a basic toggle to go back and forth between using the mouse to move the cursor, and using the mouse to move the camera, and I don’t want the mouse to be locked to the viewport, but it stays locked at first anyway. Basically, it behaves exactly as Isvulfe explained, whether you set it to locked or unlocked.
Also, when I try to toggle back to using the mouse to move the camera, I also have to click again to be able to move the camera. That’s really annoying and non-intuitive, and completely defeats the purpose of trying to set up a simple toggle.

Thank you for notifying us that you too are having issues with this bug. I will make sure the community interest on this bug is updated. Just as an update, this bug still has not been resolved and it is backlogged at this time.

If you have any further questions, please let us know. Have a great day!

Looks like this remains an issue in 4.9. Any update on the status of this issue would be greatly appreciated.

Hey,

This issue is classified as a priority 2, major issue. It’s currently backlogged and not resolved at this time though. Please check back soon for further information.

Thank you!

Any news on this being fixed in 4.10?

No update at this time. We will post here when we see any change.

Also when I set SetLockMouseToViewport(true); The keyboard input is blocked. I think it’s wrong.

Any update on this we’re now at engine 4.11 and having same issues our game is a thirdperaon shooter but we need to be able to shoot near enough unrestricted in all directions the problem is when trying to aim or move the mouse cursor will eventually get to the edge of the game window then escape the window causing several things to happen . Mostly you end up opening stuff on you’re desktop , you loose control of the game and character the game is basically unplayable like this .

UE-7293 is set as a major bug but it’s backlogged currently. I will update it to let our Developers know that it’s an important Jira.

Thanks!

Just adding my voice that this would be nice to fix.

I had the same issue. From this discussion, I resolved the issue in my C++ project by adding one line in controller class’s SetupInputComponent function.

SetInputMode(FInputModeGameAndUI());

I found the input mode change doesn’t work in constructor, so I put it in SetupInputComponent function. Now, things work as expected.

EDIT: Although this fixes the issue with the main window’s viewport issue, There is a strange problem where mouse cursor disappears for preview windows when click ‘play’ from BP editor window.

Major issue basically a game breaking bug if you have any type of game with mouse aiming in it and still no fix in five engine version . Coming epic stop releasing new features and fix the stuff you already got first please .

I currently have this problem in version 4.12.5.