how to get this area3d.name ? connect signals with parameters in code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By zyowee
func _ready():
    var area3d = Area3D.new()
    area3d.name = "area3dname"
    var coll = CollisionShape3D.new() 
    var boxshape = BoxShape3D.new()
    coll.shape = boxshape 
    area3d.input_event.connect(_on_area_3d_input_event)


func _on_area_3d_input_event(camera, event, position, normal, shape_id): 
    print("i want get the area3d.name")

i want get the area3d.name

Assuming you’re going to use this to handle more than one area 3D, you should pass the node in too:

area3d.input_event.connect(_on_area_3d_input_event, [area3d])

And you get an extra parameter:

func _on_area_3d_input_event(camera, event, position, normal, shape_id, area):
    print(area.name)

(assuming area is not null)

spaceyjase | 2023-03-03 17:37

thank you ,it’s work I’m so grateful.

zyowee | 2023-03-04 06:25

:bust_in_silhouette: Reply From: spaceyjase

Duplicate my answer from here for visibility: how to get this area3d.name ? connect signals with parameters in code - Archive - Godot Forum

Assuming you’re going to use this to handle more than one area 3D, you should pass the node in too:

area3d.input_event.connect(_on_area_3d_input_event, [area3d])

And you get an extra parameter:

func _on_area_3d_input_event(camera, event, position, normal, shape_id, area):
    print(area.name)

(assuming area is not null)

Thanks @zyowee