Removing cursor "jitter" from click to drag camera rotation

Hey everyone,

I’m working on implementing an mmo style third person camera functionality that does the following:

  1. A visible cursor

  2. Moving the mouse with the left mouse button depressed “drags” the camera about the character center without changing the character facing.

  3. Moving the mouse with the right (or both) mouse button(s) depressed “drags” the camera about the character center and keeps the character facing the camera direction

  4. The cursor position on the screen should freeze while dragging the camera.

I’ve implemented 1-3 to my liking. My solution for 4 so far mostly works but isn’t perfect. In the events on the character class blueprint, I get and save the x and y mouse positions on the screen on mouse button press. It then passes those values to a set mouse position which is tied to input axis turn and behind gate which is open while any mouse button remains pressed.

What ends up happening is that when you move the mouse to drag the camera, the cursor slightly moves, then gets set back to the original position, and this causes a repeating jitter for as long as you are moving the mouse. I realize that I could sweep this problem under the rug by just hiding the cursor during the mouse drag. But I have an explicit desire for the mouse cursor to remain visible and this also causes problems where the camera rotation doesn’t occur because of the jitter when the mouse is too close to the edge of the viewport.

I suspect what is going on is that somewhere in the default processes, Unreal is telling the cursor to move on mouse movement as if mouse buttons weren’t depressed (as one would naturally expect) and then my code says to change the cursor position back after that has occurred. If that’s the case, I assume I should be able to make a c++ subclass that overrides the default cursor functionality when my conditions are met. Assuming this is the case, the problem I’m having is finding where it is that unreal does its default cursor control.

Can anyone point me in the right direction?

1 Like