This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes
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

Godot version 4.0
in Engine by (12 points)

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)

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

1 Answer

+1 vote

Duplicate my answer from here for visibility: https://godotengine.org/qa/148385/how-get-this-area3d-name-connect-signals-with-parameters-code?show=148438#c148438

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

by (1,406 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.