TLDR: The “Set Mouse Position” node doesn’t seem to do anything when toggling UI/Game
When trying to set the input mode (between game only and game/UI), then setting the show mouse cursor boolean, the Set Mouse Position" node doesn’t seem to work at all. I have tried to rearrange the nodes around many times, but nothing has worked out.
Recreating it is easy in a new first-person-shooter template that comes with the unreal editor, as you just need to add the nodes to a new/existing BP copied from a pastebin or the screenshot below:
The only fix I found was waiting two ticks to update the mouse cursor position after showing the cursor, pictured below (Note the two added “Delay Until Next Tick” nodes):
But this causes a visible problem where now the cursor “jumps” from it’s old position to the middle of the screen
Am I doing something wrong? Is there a setting I do not know about? This is the biggest bug I’ve faced since moving from unity.
Thanks
When it comes to the original issue: is the goal of entering Game and UI mode to pop up a widget and have the cursor manifest in the screen centre, ready to be used with widgets? In which case I’d try:
After giving the widget in question focus (on the Set Input Mode Game and UI node). However, unsure how the rest of the setup looks like, and what’s the scenario / end goal is. So this might be a miss.
The thing with UMG is that widgets and the player controller often “fight” over cursor behaviour (sort of). In your example, you get ready to enter a mode where UI gets priority but then immediately ask the controller who has just lost control over the cursor to position it.
It seems that it might be a problem connected to being on linux.
I am currently on Linux mint cinnamon edition 22.1.
It might be a problem with Wayland compositor, or the linux build of the unreal editor.
The debug message is thrown, but the mouse is not centered.
If it is a problem with figuring out who has control of the mouse cursor, I fear that it’s a rabbit hole that’s beyond the scale of the project, since I don’t get enough time in a week on it
I’m still using the 5.3.1 Linux build but I can confirm that this appears to be an issue on both X11 and Wayland as I found this thread when an old project (which was possibly made under Windows) no longer works as expected.
In my own debugging I can say that the engine considers the SetMousePosition node to have worked because if you then use the GetMousePosition node and print its’ output the Set/Get values will be identical.
However, the on-screen visible Linux desktop cursor does not move to the position expected.
Edit: Actually, the cursor is updating properly as I added a UMG cursor so that I wasn’t relying on the desktop environment cursor and the UMG cursor did update its’ position correctly - but then it snapped to a wrong position the moment I moved the mouse again, so this could be an issue with my project somewhere.
In the standalone default first person shooter template, changing it to a custom mouse cursor does the same thing where it looks like the cursor was moved correctly, but then seems to snap back incorrectly.
Since this is replicable, it seems like an unreal engine problem, as playing it in a standalone window as its own process does not solve the issue.
The custom mouse cursor is a transparent 1x1 png that basically hides the mouse cursor while waiting for the two frames.
Setting the “Show mouse cursor” node false or setting the current mouse cursor to “None” will cause the cursor to not show at all unless clicked, which is why the cursor is set to remain visible, but use a completely transparent png for the cursor for the two frames
This workaround ended up not working in a standalone process window player, and caused additional mouse visibility problems.
I’ve filed a bug report on this, and have left my code to keep the cursor visible while moving, causing jumping when entering UI