My code never seems to execute "_gui_input(event)" or "_unhandled_input(event)"

Godot Version

4.4

My _process function (where I used to have the majority of my input handling happening) looks like this:

func _process(delta: float) -> void:	
	# check to see if the mouse is moving or not - surely there's a better way to do this
	if !mouse_position:
		mouse_position = get_viewport().get_mouse_position()
	var current_mouse_position = get_viewport().get_mouse_position()	
	var mouse_moved = current_mouse_position - mouse_position
	
	if mouse_moved:
		mouse_position = current_mouse_position

	if new_module:
		if mouse_moved:
			new_module.global_transform.origin = get_3d_mouse_position()
			if new_module.has_overlapping_areas():
				for overlapping_area in new_module.get_overlapping_areas():
					# this is probably horrendously slow but check to see if it is overlapping with it's own stuff
					if !is_own_child(new_module,overlapping_area):
						new_module.set_appearance("blocked")
						valid_build_location = false
					else:
						new_module.set_appearance("ghost")
						valid_build_location = true
			elif no_modules():
				new_module.set_appearance("ghost")
				valid_build_location = true
				is_snapped = false
			elif !is_snapped:
				new_module.set_appearance("blocked")
				valid_build_location = false
			else:
				new_module.set_appearance("ghost")
				valid_build_location = true
				is_snapped = false
		else:
			snap(new_module)

I tried moving all of the event handling to the _unhandled_input(event) function and it simply does not execute. If I rename that function to _input(event), the game works as it did before I moved everything out of process. My “_unhandled_input(event)” function looks like this:

func _unhandled_input(event: InputEvent) -> void:
	print("unhandled event: ", event.name)
	
	if new_module:
		if Input.is_action_just_pressed("Select"):
			if valid_build_location:
				if no_modules() or is_snapped:
					new_module.build()
					#add it to the module array
					module_array.push_back(new_module)
					
					new_module = null
					is_snapped = false
		elif Input.is_action_just_pressed("Rotate Module Down"):
			new_module.rotation_degrees.x += rotation_increment # rotate down
		elif Input.is_action_just_pressed("Rotate Module Up"):
			new_module.rotation_degrees.x -= rotation_increment # rotate up
		elif Input.is_action_just_pressed("Rotate Module Left"):
			new_module.rotation_degrees.y -= rotation_increment # rotate left
		elif Input.is_action_just_pressed("Rotate Module Right"):
			new_module.rotation_degrees.y += rotation_increment # rotate right
	elif Input.is_action_just_pressed("Select"):
		print("somehow got to the select area")
		select(get_mouse_intersect_object())
			
		if currently_selected_object:
			# show the module stats panel
			module_statistics_panel.set_up_stats(currently_selected_object)
			module_statistics_panel.visible = true
							
		else:
			# hide the module stats panel
			module_statistics_panel.visible = false
			
	elif Input.is_action_just_pressed("delete_module") and currently_selected_object:
		if currently_selected_object.is_selected():
			# check to see if it's a docking port then unselect it
			if object_is_module_type(currently_selected_object, ModuleType.DOCKING_PORT):
					select(currently_selected_object)
			else:
				# disconnect it from station:
				if disconnect_module_from_station_and_delete(currently_selected_object):
					delete_module(currently_selected_object)
			
			#currently_selected_object.set_appearance("built")
			currently_selected_object.revert_status()
			currently_selected_object = null
			
	if Input.is_action_just_pressed("cancel") and new_module:
		# canceling the build attempt
		new_module.delete_self_and_all_children()

it NEVER prints "unhandled event: ", event.name to the console.

I do have an _input function elsewhere but all it is doing is handling the camera movement (mouse look) functionality and looks like this:

func _input(event):
	if Input.is_action_just_pressed("mouse_look"):
		mouse_look_enabled = true
	elif Input.is_action_just_released("mouse_look"):
		mouse_look_enabled = false
			
	if event is InputEventMouseMotion and mouse_look_enabled:
		if flip_rotation:
			global_position = orbit_point(target, global_position, -1 * (event.relative * rotation_amount))
		else:
			global_position = orbit_point(target, global_position, event.relative * rotation_amount)
		
		look_at(target)

	if Input.is_action_just_released("camera_zoom_out"):
		look_at(target)
		var zoomed_out_cam_gp = global_position + ((global_position - target) * zoom_speed)
		global_position = zoomed_out_cam_gp
	elif Input.is_action_just_released("camera_zoom_in"):
		look_at(target)
		var zoomed_in_cam_gp = global_position - ((global_position - target) * zoom_speed)
		if zoomed_in_cam_gp.distance_to(target) > zoom_in_threshold:
			global_position = zoomed_in_cam_gp

Anyone got any idea what is going on?

Sounds like your input is handled elsewhere, maybe you have other GUI layered on top of it. What does your scene tree look like?

Godot Engine v4.4.1.stable.official.49a5bc7b6 - https://godotengine.org
Vulkan 1.3.289 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 3070 Laptop GPU

┖╴GameRoot

┠╴WorldEnvironment
┠╴Camera3D
┠╴StationManager
┃  ┖╴BaseModule
┠╴UI
┃  ┠╴MenuBar
┃  ┃  ┖╴Build
┃  ┃     ┠╴@PanelContainer@2
┃  ┃     ┃  ┖╴@ScrollContainer@3
┃  ┃     ┃     ┠╴@Control@4
┃  ┃     ┃     ┠╴_h_scroll
┃  ┃     ┃     ┖╴_v_scroll
┃  ┃     ┠╴@Timer@5
┃  ┃     ┠╴@Timer@6
┃  ┃     ┠╴CoreModuleBuildMenu
┃  ┃     ┃  ┠╴@PanelContainer@7
┃  ┃     ┃  ┃  ┖╴@ScrollContainer@8
┃  ┃     ┃  ┃     ┠╴@Control@9
┃  ┃     ┃  ┃     ┠╴_h_scroll
┃  ┃     ┃  ┃     ┖╴_v_scroll
┃  ┃     ┃  ┠╴@Timer@10
┃  ┃     ┃  ┠╴@Timer@11
┃  ┃     ┃  ┠╴BasicCoreModules
┃  ┃     ┃  ┃  ┠╴@PanelContainer@12
┃  ┃     ┃  ┃  ┃  ┖╴@ScrollContainer@13
┃  ┃     ┃  ┃  ┃     ┠╴@Control@14
┃  ┃     ┃  ┃  ┃     ┠╴_h_scroll
┃  ┃     ┃  ┃  ┃     ┖╴_v_scroll
┃  ┃     ┃  ┃  ┠╴@Timer@15
┃  ┃     ┃  ┃  ┖╴@Timer@16
┃  ┖╴ModuleStats
┃     ┠╴ModuleName
┃     ┖╴ThrusterControls
┃        ┠╴ModuleName2
┃        ┠╴ThrustSelecter1
┃        ┠╴ModuleName3
┃        ┖╴ThrustSelecter2
┠╴Europa
┃  ┖╴PlanetAthmosphere
┃     ┠╴@MeshInstance3D@122
┃     ┖╴@Node@125
┃        ┖╴@SubViewport@124
┃           ┖╴@Sprite2D@123
┠╴Jupiter
┃  ┖╴PlanetAthmosphere
┃     ┠╴@MeshInstance3D@126
┃     ┖╴@Node@129
┃        ┖╴@SubViewport@128
┃           ┖╴@Sprite2D@127
┖╴Sun
   ┠╴DirectionalLight3D
   ┖╴CSGMesh3D

Certainly a lot of UI, which is prone to consuming or “handling” inputs so they do not spread to _unhandled_input functions. It may be better to use _input in this case, or track down which of your control nodes is intercepting what I assume is mostly mouse inputs.

Actually i think i found the issue…need to handle every gui interaction or it drops out