Problem with mouse input

What can cause mouse-axis input to be captured(?) only while a mouse button is being pressed?

I’ve ignored this problem for some time, but it needs fixing now. I am controlling a character in 3rd person and it only rotates or looks up/down with mouse movement, while I’m pressing any of the mouse buttons, which is rather absurd…

I noticed there is a setting for this kind of thing under project->input, but it’s set to capture permanently. Maybe my GUI-wigets are absorbing input until the focus is forced to the game-view by clicking (holding) on it, but I really don’t know.

Are you doing anything with the mousebuttons in your code/blueprints?

LMB is for shooting, the others don’t do anything atm. I am pretty sure, only the pawn/character has bound actions for them.

I monitored the values passed to the mouse-axis input functions (from the character). They are always zero until a button is being held.

edit: I also removed the widgets completely, but it’s still the same.

I probably should have mentioned I am using a “GUI and Game” control mode for the player controller. Maybe it’s always like that for that mode? I think I may have to use “Game only” for permanent mouse capture…

Could you pass an image of your input settings? Axis mappings and Viewport properties…

Thanks for replies, but I think I figured it out.

Looks like this behavior is normal when setting an input mode for a player controller of type FInputModeGameAndUI. I thought I could use that mode throughout and switch between direct controls and GUI by toggling cursor-visibility. But I guess I have to toggle the input mode instead from FInputModeGameOnly, where mouse capture is permanent, to one of the two others.

i have the same problem, but your solution didnt work for me. where you set this input mode? also where you store the input mode variable? for example i tried to set it in players controller constructor, using SetInputMode(InputMode); where InputMode is controller’s field of type FInputModeGameOnly. because i afraid that if i use SetInputMode(FInputModeGameOnly()); that input mode variable would be allocated on stack and will be destroyed after constructor completes. but i’m not sure about this

It’s been half a year and I don’t really remember what the problem was ^^
Looking at my code however, it turns out I’m still using “GameAndUI” after all.

I’m setting the mode in PC::BeginPlay like this:

FInputModeGameAndUI mode;
mode.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock);
mode.SetHideCursorDuringCapture(false);
((APlayerController*)Controller)->SetInputMode(mode);

I manually control inside axis input functions whether I want to pass the mouse input to the controller (PC::AddYaw/PitchInput) or not, and I simply toggle cursor visibility to switch between modes. During freelook mode (cursor hidden), I keep resetting the cursor to the center of the viewport. I think this was necessary to prevent the cursor from eventually getting blocked by the edges of the screen, so you suddenly weren’t able to turn any further, and probably also to prevent clicking outside the game window. It’s possible there are better ways of dealing with this, but it works for me and allows for flawless freecam and cursor behavior, both in fullscreen and windowed.

edit: the input mode variable (structure) doesn’t need storing. I haven’t checked, but I’m sure “SetInputMode” will copy or extract the data it needs for the PC class.

I used “set input mode Game only”,and sloved the same problem. Have you try this?