Camera input in a top down game - different left/right mouse capture behavior

I’m working on a top down game. Simple controls: Left click to move. Right click to rotate the camera.

That’s easy enough to do. But I want the mouse to disappear and remain still while I’m turning the camera with right click. That’s also easy enough to do!

Voilà! It’s done, right? Well, not really. Now I can’t hold left click to move, cause as soon as I do, the game registers that as a “mouse capture” and proceeds to hide/lock the cursor.

So yeah, I need this hide/lock behavior for my right click, but not left click. But UE doesn’t let me customize mouse captures, or manually trigger them, or provide an alternative way to hide/lock the mouse. Multiple hours watching every YouTube video out there, and every forum post on the topic, and I still have absolutely no idea how to do this very simple thing. I’d very highly appreciate any help.

Thanks in advance!

Hey @Gaeta27!

So the “Capture” is just what keeps the mouse within your game window. You definitely want to keep your “hide cursor during capture” set to false!

Try something like this:


Give that a try and let me know how it goes!

1 Like

Thank you, that worked flawlessly!

I was trying to do something similar earlier but I gave up cause the getter being a float, while the setter is an int, sounded like a redflag to me and I was trying to multiply by the viewport size to make up for it, hahah. Doing it like you showed works perfectly. Thanks a lot, cheers!

@Gaeta27 You’re very welcome! Truncating is very cheap, especially if they’re already whole integers. It is weird that it saves that way since it’s saving pixel X and pixel Y which are always Ints, but Vector2 is 2 float values so it is what it is.

If you have any more issues, be sure to send them our way :smiley:

1 Like