area2d signal problem

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

hi i have the body_entered signal to the emitting node itself , here’s the code

func _on_Area2D_kts_body_entered(body):
	if body.get_parent().get_parent().get_name() != "map" :

even though the grandparent node name is map , it still execute the condition block
any help would be great

:bust_in_silhouette: Reply From: jgodfrey

While I don’ t necessarily see the problem, your code doesn’t seem to be the most useful way of trying to find it. I wonder if your name has one or more trailing spaces? Does something like this help track it down?

func _on_Area2D_kts_body_entered(body):
    var name = body.get_parent().get_parent().get_name()
    print(">" + name + "<")
    if name != "map":
        print("name is not map")

not it but thx

kietjay123 | 2020-08-28 07:14