Left mouse click takes me out of the editor/game


I had this working in 4.13.2. Being able to left click on actors and then hold the right button down to look around and being able to right click on actors.

I had a timer on my right moust button (RMB) click for .2 seconds that set a bool for the RMB being held. Then in my custom player controller I overrode the AddPitchInput and AddYawInput.

First question, is there a way to make this work? What I have read over the past versions is NOT encouraging. Looks like Epic says “Move the mouse aims, left button is for firing, right click hold is for zooming in”.

I stripped everything down where I am logging the up and down for both buttons. As soon as a I left click, the cursor jumps out of the game, as if I had pressed SHIFT-F1. My Project settings under Input, Viewport properties are set for Capture Mouse on Launch, Capture Permanently Including Initial Mouse Down and Lock on Capture.

I am in the process attempting to set the viewport directly when beginPlay on the character, but I am not sure that is the right path.

*I am building against source if that makes any difference

I have determined that multiple settimer and clearing the timer is not responsive enough for tracking the RMB hold. It’s funny, I want similar functionality in my game as I get in the Editor. Right click and hold to move the camera, quick right click to do another action like pull up a menu.

When I hide the cursor, my right click and left click work just fine.

Even my timer for holding down the right button works fine … as long as I don’t show the cursor.

My goal is to have cursor flexibility like we do in the Editor.

I want to be able to use the mouse cursor to select with left click, right click to up a menu, right click hold to look around.

So far my research on this makes me conclude that the Unreal Engine 4 expect the mouse only be used for interacting with the UI widgets. Use a targeting reticle for selecting actors and then a key (like “E”) to pickup, open, etc.

10+ hours into trying to get this worked out…

If I don’t have the following code in my C++ player controller, my mouse clicks are responsive. I was running this code in my Yaw input method which means it was getting called ALOT.

FInputModeGameOnly GameMode;

Now I have the issue of the “look” stopping when the cursor gets to the edge of the screen which was what the above code was supposed fix. Thank you to Panda Studios with their Character Stats kit to show me that what I am trying to do is not that far off base.

Do this in BeginPlay of the player controller

FInputModeGameAndUI GameModeUI;

Now all my hiding and showing of the cursor depending on the timer I set on the right click down event is working as I desired.

Do not set the input mode in a yaw method.

The cursor now leaves the window all the time, but my original issue is addressed.

This totally breaks when I run in Standalone. I get the cursor off in the upper left of my screen and every time I move it towards the game window, it flickers back. Totally unusable. I have three monitors off my computer. Wonder if this affecting it.