How do I detect when the mouse is not moving?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Macryc

Hi All. I want the game to call a function when the mouse isn’t moving. Something like:

func _unhandled_input(event):
	if !event is InputEventMouseMotion:
		print("dead mouse")

which is silly and doesn’t work, but you get the idea…
How do I do that?

:bust_in_silhouette: Reply From: deaton64

Hi,

This maybe:

extends Node2D

var _old_mouse = Vector2.ZERO

func _process(delta: float) -> void:
	if get_global_mouse_position() != _old_mouse:
		print("mouse moving")
	else:
		print("mouse not moving")
	_old_mouse = get_global_mouse_position()