Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

No problem, for mine I put something like:

func _input(event) -> void:
	
	#---------------------
	# Replace with your own implementation of MOUSE_MODE switching!!
	#---------------------
	
	if Input.mouse_mode != Input.MOUSE_MODE_CAPTURED && !disable_input:
		#if event is InputEventKey:
			#if event.is_action_pressed("ui_cancel"):
				#get_tree().quit()
		
		if event is InputEventMouseButton:
			if event.button_index == 1:
				Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
		return
	
	#if event is InputEventKey:
		#if event.is_action_pressed("ui_cancel"):
			#Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
		#return
	
	if event is InputEventMouseMotion:
		if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
			# Grab the event data and process it.
			gather_mouse_input(event) 

Then I make sure that when the mouse is supposed to be unfocused I disable the process_mode on the mousehandler, uncapture the mouse, then wait for the focus to come back, then recapture when clicked.

thanks for the tip! i’ll look into it 🙂