Get node own child area2d when area_entered

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RyuShai

i make test tree like:
Test
…|_Slot (slotScript)
…|_area2d (listen area_entered)
…|_temp_item
…|_Item(itemScript)
…|_item_area_2d

function
func _on_item_slot_area_entered(area):
only give object : “item_area_2d” but i need “Item” object to assign temp_item = Item
how can i do it ?

func _on_item_slot_area_entered(area):
        print(area.get_parent().get_node("Item"))
        or 
        print(area.get_parent().get_parent().get_node("Item"))

ramazan | 2022-03-05 07:44

ty for your answer. May be example above too simple to discription my situation.

im try drag “item” to “item_slot” (both have area2d) by 2 signal
1 item enter slot area
2 mouse is release

but “item_area” deep is different among others item and “item” name different too so i cant call multi times get_parent() because i dont know how deep “item_area” are.

each item are scene it self

i’m looking for solution help me determine which “item_area” parent without call get_parent or must know node name. Example above node “Item” is what i want

  • other small problem: how make text indent by tab in comment ?

RyuShai | 2022-03-05 15:15

:bust_in_silhouette: Reply From: RyuShai

i solve my problem by my self after few test (actually after many digging ).

area.owner extractly what i looking for

ty