Godot 4.4
I have multiple clickable objects that overlap each other set as Area2Ds. Is there a way to only be able to click on the front-most object, and not impact the objects behind?
I know this can be done with TextureRects, but because many of the objects are irregular, I want to work with Area2Ds.
This is the way I tried to enable the functions. I called it in the main script. It didn’t seem to effect the ordering:
func set_physics_object_picking_sort(value: bool):
value = true
func set_physics_object_picking_first_only(value: bool):
value = true
That’s not how to do that, you need to set it on the viewport, you can’t just add your own methods for that, use get_viewport()
Should it be something more similar to this?
func _ready() -> void:
get_viewport().get_physics_object_picking_sort = true
get_viewport().get_physics_object_picking_first_only = true
1 Like
Hi, Idk if you managed to fix your code, but the snippet you presented is incorrect. There are no properties called get_physics_object_picking_sort or get_physics_object_picking_first_only on the viewport. Instead, you need to use physics_object_picking_sort and physics_object_picking_first_only. So just remove the get_ and it should work fine.
1 Like