How to stop collision input behind collision2D

Godot Version

4.3

Question

I want two overlapping collision2Ds in a scene, but I want the collider on top to be the one to respond to input. Does anyone know how to do this?

I would like to be able to do this with two Area2D’s, where one is infront of the other. Or is there a better way to do this?


Could you add a blank Control and then connect the _gui_input() signal passing it a custom string value to detect which was clicked?

func _on_control_gui_input(event: InputEvent, node_info: String):
	if event is InputEventMouseButton and event.is_pressed():
		print("Clicked ", node_info)		
		pass

Have a look at Viewport.physics_object_picking_first_only and Viewport.physics_object_picking_sort which allow you in combination to do just that.