Area2d doesn't detect CharacterBody2D after i changed godot 3.5 to godot 4.0

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

This is my code:

func _on_dialog_detection_zone_body_entered(body):
	label.visible = true

func _on_dialog_detection_zone_body_exited(body):
	label.visible = false

I started coding on godot 3.5. Everything worked great for me there. I’m using this code to display text when a character approaches an NPC. After switching to godot 4, Area2d stopped detecting CharacterBody2D, please help me understand what is wrong with this. I tried reconnecting the body_entered and body_exited signals, but that didn’t help. I checked, the collision layers are ok. I tried adding an Area2d node to the character and using the area_entered signal, but that didn’t help either.

is monitoring set to true on the area?

fuck | 2023-03-03 11:29

yes, I tried changing this parameter to false and then back to true. that didn’t help

koval_dev | 2023-03-03 11:33

Are there green symbols next to the functions in the script?

exuin | 2023-03-03 12:29

Yeah, there are green symbols. The signals are connected

koval_dev | 2023-03-03 13:19

:bust_in_silhouette: Reply From: Miguelino

Have you tried swapping the Area 2d and corresponding kinematic nodes from scratch?

:bust_in_silhouette: Reply From: aidave

Double check your physics layers and collision shapes.

Some shapes like Capsule changed their size after conversion

Thanks. I checked and found the problem)

koval_dev | 2023-03-04 19:03

:bust_in_silhouette: Reply From: koval_dev

Oh, I just mixed up the purpose of the collision layer and the collision mask

Description in documentation:

collision_layer:    
The physics layers this CollisionObject3D is in.

collision_mask:
The physics layers this CollisionObject3D scans.

But I specified a collision layer instead of a collision mask in my Area2d. And because of that, Area2d couldn’t detect that the body had entered. So I just changed that to collision mask for Area2d and collision layer for CharacterBody2D and it worked.

Strange that this worked for me in godot 3.5 =)