How can I know when the player stops moving the mouse?

Hi!

I need to know when the player stops moving the mouse.

To test it, I’m using the third person template to know when the user stops moving the mouse:

I think I have to use the Completed event but it is full of “warnings” to avoid using (if I have understood the caption correctly):

My goal is to determine whether the player has not moved the mouse for three or more seconds.

How can I do it?

Thanks!

Hello @ViaCognita ,

I wouldn’t use the Completed pin in this case, because mouse movement works differently from a key press. Instead, use a Timer that resets every time the mouse moves. If the timer finishes, it means the mouse has been still for that amount of time.

First, create a Custom Event called MouseStopped, which will execute when the mouse stops moving for the specified amount of time.

Then, inside the Aim function, right after Add Controller Pitch Input, add a Set Timer by Event node, set the desired time ,in your case, 3 seconds, and disable Looping. Promote the Return Value to a Timer Handle variable to store the timer.

Before Set Timer by Event, add Clear and Invalidate Timer by Handle and connect the previously created variable to cancel the previous timer every time the mouse moves.

Finally, on the Event pin of Set Timer by Event, use Create Event and select the previously created MouseStopped Custom Event.

This way, every time the mouse moves, the timer resets. When the mouse stops moving, the timer finishes and the custom event “MouseStopped” is executed.

Hope it helps!

mouse movement basically runs on tick so you may as well use that, you could also use MousePositionInViewport and check if its moved beyond a threshold