I’m working on an RTS style interface. The camera is panning based on mouse movement and in general works great as long as the mouse cursor is hidden.
If I call PlayerController->SetShowMouseCursor(true) then everything gets messed up.
With a visible mouse cursor, character movement and camera panning works fine UNTIL I click the right or left mouse button. As soon as I click one of those buttons, then camera panning STOPS ENTIRELY and there is no way to get it back. It seems that Unreal hijacks the mouse once I click something.
Again, note that this IS NOT A PROBLEM if I leave the mouse hidden. It is specifically the call to PlayerController->SetShowMouseCursor(true) which seems to be the problem.
Is there some other different/better way to show the mouse cursor that doesn’t have these unintended consequences of completely breaking the input system?
(In case it matters, I’m using Lyra’s Enhanced Input System, but from what I’ve read, this seems to be a fundamental issue with UE’s input handling; It’s not at all clear how to solve this except perhaps to implement my own mouse cursor and NOT use the system PlayerController mouse cursor, but surely there is a better way?)
I don’t know if this will work, but maybe setting a lock on your mouse events will keep the hijack from happening. Use a boolean and branch to set the lock during these pans.
If the mouse still works after that, then I don’t know what’s going on and you may want to bring it up to Epic.
I’m using the Enhanced Input System that Epic set up for LyraStarterGame.
The one and only change that I’ve made is that I changed the input such that the mouse input doesn’t pan the camera unless the middle mouse button is also pressed. This way I can move the mouse around the screen and click on things independently of panning the camera.
I’ve done nothing at all with the left or right clicks, which are the things that are breaking the input IF and only if the mouse cursor is visible.
Somewhere deep in UE it’s doing something like “if cursor is visible, don’t let mouse input get to the game.”
I’ve tried various forms of SetInputMode() but none of them seem to do what I want, which is to have the mouse be visible AND still send the enhanced input system mouse movement events to the game.
To follow up, I’m several hours into this problem and I haven’t been able to find any way to do this the “right” way, if there is such a thing.
Instead, I’m just leaving the mouse invisible and I created a custom HUD class that draws a rectangle where the mouse is supposed to be. It’s crude, but at least the input consistently works now.
I guess at some point I’ll try to make it look like a mouse.
Same Issue here, but in third parson.
After opening widget im showing cursor removing mapping and add new mapping then on close im removing mapping and adding old one, cursor is hidden but camera dont recive any input, i need to click to get back mouse capture.
For now i have put " set input mode Game Only " at the end and it works
I found a solution for this problem, thought I am a complete amateur with Unreal Engine still. You need to change 2 different settings sections to get it working.
In project settings, search for Mouse under Engine Input, and set them to this:
In your PlayerController class, in the Details panel, search Mouse, and set them to this:
I met this problem,and I didn’t resolve it.
So I just check if the mouse position close to the screen edge.
If mouse is at the edge I’ll add a constant movement to the camera.
Your solution does indeed work for some use cases.
The solution that I posted is a bit more involved, and will work in 100% of use cases. For more details see the tutorial request link, it contains the entire problem set and a link to a blog explaining some of the edge cases as well as a video demonstrating some of the other related problems and how to fix them.
If your solution works perfectly for your game, there is no reason to make it any more complex. However if you notice that it’s not working the way you want, then you’ll want to look at my solution for the fix. (TLDR showing and hiding the mouse repeatedly will forcefully recenter the mouse due to CommonUI, and my solution is required to fix that).
Hopefully Epic provides more configurability to CommonUI in subsequent versions but as of 5.3 my solution is the only way to truly control the mouse.
This means any time I want to show/hide the mouse as a part of normal game play I need to explicitly manage the input mode and mouse capture settings every time the mouse visibility changes.
Does this suggest it’s possible to force on input mode/mouse capture after setting the mouse visible without the overrides and rewrites you described? I ask because I’m a beginner to programming with UE and using blueprint and this solution is a bit beyond me. I hoped to simply be able capture the mouse input values inside my mouse-controlled pause menu. I’ve tried as much as I could think of with no luck.
The answer is entirely dependent on the type of game you’re making and whether or not you are based on Lyra. If you’re making a shooter based on Lyra, it’s fairly easy. In any other case, it requires a fair amount of non-intuitive-and-not-well-documented C++.