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?