In a top-down building placement game I am using “Set Input Mode Game And UI” in order to allow both UI actions and the player controller to move the camera. Option “Hide Cursor During Capture” is set to True, in order to lock and hide the cursor while the camera is rotated and moved via RMB and MMB. The problem is that I cannot seem to find the option to exclude LMB from capture. As it is now, clicking and holding LMB makes the cursor disappear, which I do not want as I use it for placement.
I tried setting “Hide Cursor During Capture” to false, and hiding the cursor manually when camera operations happen. The problem is that in this mode the cursor is not centered. The hidden cursor runs out of screen space and camera cannot be moved further. Manually centering the cursor while hidden breaks input actions as they are considering no movement is made.
Thanks for the idea, just tried it. As you noted, this doesn’t capture the mouse on MMB, so the cursor is still shown. But, it introduces another problem: when mouse isn’t captured, the game does not receive events. So in this solution neither LMB nor MMB events are passed to the game.
So, I should reformulate the problem: I want the cursor to be captured, but hot hidden, just on LMB.
Well you could try putting the capture mode as “Capture Permanently Including Initial Mouse Down”.
Then in your Right Click and MM Click input events, call a function that handles the camera rotation input, but also enables and disables “Show Cursor”.
These also trigger a boolean on the player controller. This way in your widgets you can override “On Preview Key Down”, and it can check if that boolean is active on the controller. If the boolean is true, pass unhandled, if its false, pass handled.
This way you can’t still Left Click UI elements while you’re rotating the camera