[RESOLVED] Mouse delta when mouse at edge of screen = 0

Hey everyone,

So I have my cursor showing and when I Right Click + Alt I am getting the mouse delta. But when ever the mouse hits the top, bottom, right or left of the screen it stops giving mouse X & Y delta and instead returns a value of 0.

It seems to work as long as I never show the mouse cursor at any time but if I hide the mouse cursor it still stops mouse X & Y values after you get to the edge of the screen.

Just wondering if there is a work around or if this may be a bug.

If you define your mouse input as an axis in the project settings in the Input tab then the axis value would give you the mouse delta no matter where your cursor is on the screen.

It doesn’t on my end. Can you send a screenshot of your blueprint?

Yeah I attempted this hoping this might have been a solution how ever it still has the same problem as when you get mouse delta or mouse x/y. As soon as the mouse cursor hits the edge of the screen it stops receiving a value and instead returns a value of zero.

Ok so here is the basic setup I did in a new project to ensure I wasn’t somehow banging thigns up in my main project.

Here are my project settings:

Edit: ah I just noticed but MouseXAxis is bound to Mouse X in case it wasn’t already clear.

Here is the basic graph where I have a gate that is opened when I hold down the right mouse button that then returns the MouseXAxis value:

And here is the final result when I try and get a result when still moving my mouse left even when it hits the edge of the screen:

As you can see I’m getting a value of zero. Even when I hide the cursor as part of the gate even or the button pressed event it still returns a result of zero because for some reason even after hiding the cursor it still tracks the cursor position.

The only time it does start to work is when I put the “Show Mouse Cursor = false” node the mouse pressed or after the gate, but only one the second time I activate the mouse pressed or mouse down.

So yeah, as you can see below I’m using an input axis instead of just the mouse X/Y or get mouse delta node but same result.

Hi Miroac,

First off, which version of the editor are you using?

The GetMouseX node will always return it’s input unless the input is disable and then it will return 0. Even if the mouse is hidden, it is still technically taking input unless it is disabled.

Also, the GetMouseX & GetMouseY return the mouse movement, not the screen position. Anytime the mouse stops, whether it is on the edge of the screen or not, it will register 0.

Ah, are you talking about how the GetMouseX will register 0 even if you are ‘moving against’ the left and right of the screen?

Hey TJBallard, I’m using 4.7.3 and yeah it is registering as 0 when it is “moving against” the left/right of the screen. The issue here is that I’m putting “Show Mouse Cursor = false” when I hold down right mouse button, then I am trying to use the mouse X value to rotate the camera.

In theory this should have hidden the mouse and I should be able to move my mouse left and right with abandonment to make my camera move, how ever I get a zero result (while the mouse is hidden) that stops my movement. It was easy to see that even though I had hid the mouse it was still registering the cursors location and returning a zero result when pushing against the edge of the screen.

This is an issue because I’m using the mouse X value to rotate the camera while the mouse cursor is hidden, so having it block the input and return a 0 while the mouse is hidden defeats the purpose of the blueprint.

The only time this works properly is if I never show the mouse cursor again and then hold the right mouse button a second time. Since the mouse is already hidden for some reason it no longer registers the mouse cursor movement against the edge of the screen. How ever this also defeats the purpose of the blueprint since I’m using the mouse cursor for gameplay.

I see the issue that you are talking about. I believe I found a workaround but I want to make sure that it is has a similar setup to what you are trying to do.

Right now I have it where you have full movement control on spawn and you can toggle the mouse on and off. While the mouse is toggled on, click events are enabled and movement is disabled until it is toggle back off again. Is that about right?

That about sums it up. Basically so that you know what I’m using to toggle, on my setup I am using Alt + Right Mouse Button Down as my toggle for movement & hide mouse on and Alt + RMB Up as my disable movement, show mouse + enable click events.

Okay, give this a try. The toggle is a little different than what you are using but it should work about the same. The trick is to use the ‘Set Input Mode Game Only’ node. It puts focus back onto the viewport after the ‘Show Mouse Cursor’ is set to false.

1 Like

Thankyou TJ Ballard for the feedback. So for all those who stumble across this issue the answer was pretty simple as soon as TJ Ballard.

You simply need to ensure that you use the Set Input Mode Game Only (and ensure that you connect your player controller into the target or it fails) and than you can get mouse X and mouse Y input even when pushing against the screen.

I tested this with the mouse both hidden and shown and it works on both occassions.

Thanks again TJ Ballard.

You were able to get this to work with mouse shown? It does not work for me. I have it set up like this: Event Begin, Show Curser True, Set Game Mode Only. If I get to edge of screen with this setup, as stated above, the mouse x/y becomes 0.
Engine: 4.9

Yeah I got it working with the mouse showing. I’d suggest changing where your “Set Input Mode Game Only” node is.
I was using it on the Alt Key event, that way it would fire when I tried to rotate the camera.
If you are just moving the mouse to the end of the screen, it may work if you put it on the X Axis and Y Axis input events.

This worked perfectly! I never thought to set the game mode off of my mouse events! Something must be resetting the game mode since you would think you could just set the game mode once, instead of every time you move your mouse!

For anyone still looking at this, I needed my input mode to be ‘Game and UI’, but was able to solve it by setting the ‘Mouse Lock Mode’ to ‘Lock Always’. This keeps the mouse locked inside the game window and it doesn’t snap to 0 at the edges.