Mouse axes are zero when there is no mouse press

This is how I try to use mouse axes

[/Script/Engine.PlayerInput]
!AxisMappings=Empty
+AxisMappings=(AxisName="MoveForward", Key=MouseY, Scale=1.f)
+AxisMappings=(AxisName="MoveRight", Key=MouseX, Scale=1.f)

!ActionMappings=Empty
+ActionMappings=(ActionName="MouseClick", Key=LeftMouseButton)

Then I bind actions and axes in C++

BIND_ACTION(InputComponent, "MouseClick", IE_Pressed, &APlayerPawn::OnMouseClick);
BIND_AXIS(InputComponent, "MoveForward", &APlayerPawn::OnMoveForward);
BIND_AXIS(InputComponent, "MoveRight", &APlayerPawn::OnMoveRight);

When I start game from Visual MoveForward and MoveRight functions receives proper axis values. But when I click mouse button this functions receives only zero values until left or right mouse button pressed.

What am I doing wrong?

Still same thing with GetInputMouseDelta() on Beta5 for me.
GetInputMouseDelta() returns zeroes till you press any mouse button. So for me, i can use it only if i hold one of mouse button.
Did this bug was removed in beta 5 or still not?

How to reproduce this bug:
in playercontroller’s ProcessPlayerInput():

FVector2D MousePos;
GetInputMouseDelta(MousePos.X, MousePos.Y);

and try to look what will be in MousePos when you only moving mouse, and when you holding any mouse button and moving mouse

in beta 6 still same bug.
when will it be fixed? :frowning:

Hi . I was wondering if I could a bit more details on your setup and the specifics of the issue you are seeing.

I setup my DefaultInput.ini as you specified and then bound the axis and action events in the level blueprint to print out the values that the events received. My experience was that the mouse delta values coming in through MoveForward and MoveRight appeared as expected regardless of whether the left mouse button was pressed or not once the window had mouse capture.

mousebindings.jpg

If you use this same setup do you get the same problematic behavior? There was a bug that could have lead to what you see in Beta3 but should be fixed in Beta4.

Just checked. With this setup behavior is the same. I think the problem in setup. I am using PlayerPawn class inherited from APawn. So maybe there are some variables that needs to be configured.

Can you confirm that you are using Beta 4? When you do Help → About what is the Version #?

Can you give me more details as to why you think you might a problem in the setup? I can’t really think of anything you could do variable wise that might have such a behavior.

It might also be useful for you to try using a new project based on something like the first person template and try this setup there as well.

I am using build 1808360.
I created project with this behavior. You can find it on FTP in AlexNovitsky folder.

Just wondering if someone has a chance to reproduce this issue with my sample project?

Hello ,

Are you experiencing this issue on Beta 6?

Thanks,

Sean

I am not exactly sure what all is going on here

but here’s a solution if you want to get the mouse position in screen coordinates at any time :slight_smile:

.h

float MouseX;
float MouseY;

.cpp

void AVictoryGamePlayerController::UpdateMouseCursor()
{
	
	//set the values of MouseX and MouseY
    	GetMousePosition(MouseX,MouseY);  //playercontroller.h
}

I run the above in my player controller’s PlayerTick function

What exactly are you trying to do with the axes?

Actually I’m trying to use mouse axes for camera movement, so I need deltas.
I know that I can store mouse position each frame and calculate deltas, but I think that using axes is much more suitable.

If you just want mouse delta, I highly suggest you use

playercontroller.h

/** Retrieves how far the mouse moved this frame. */
UFUNCTION(BlueprintCallable, Category="Input")
void GetInputMouseDelta(float& DeltaX, float& DeltaY) const;

You can run this every tick in a custom player controller class or on a timer via blueprints (it is blueprint callable)

Enjoy!

PS: also you should consider responding with comments, not by the bottom-most portion which means you are giving an answer to the problem :slight_smile:

Thanks for your answer. In fact I already tried to use this functions and it behaves the same. It returns non zero deltas only when one of the mouse buttons is pressed. Maybe there is some magic boolean switch. I don’t know. )

Since i got the same problem here, no matter if i get the axes from InputBindings or from GetInputMouseDelta, i always only get values != 0 when i do a mousepress too, is there any solution to this?

Thanks in advance,

Hi indygoof,

Please make a new post about your specific concern. This is an archived post from pre-release. Closing the thread as outdated. Thank you!