Area2D not detecting CharacterBody2D

Godot Version

Godot 4

Question

I’ve got a CharacterBody2D thats meant to just slide to the left when playing and stop when paused. The movement works fine, but I have a few Area2D nodes, two within my base script alongside the CharacterBody2D, and one as a child of a Panel node in my base script. All three Area2D nodes can detect mouse_entered / mouse_exited. All three Area2D nodes and the CharacterBody2D node are set to collision layer/mask 3. Does anyone know why the Area2D nodes are not detecting when the CharacterBody2D node enters? Thank you!

#CharacterBody2D movement code
func _play():
	velocity = velocity.lerp(Vector2(1.0, 0.0).normalized() * speed, accel)

func _pause():
	velocity = velocity.lerp(Vector2.ZERO, fric)

func _physics_process(_delta: float) -> void:
	move_and_slide()


#one of my Area2D nodes - the CharacterBody2D is in the group "line"
func _on_end_measure_body_entered(body: Node2D) -> void:
	if body.is_in_group("line"):
		movingLine.position = Vector2(59.0, -147.0) #this line will not trigger

Does the function itself get triggered? Can you put a print statement just before your if statement to see if the function works?

the function itself will not trigger

Do you have the correct signal connected? Can you show us your scene tree?

Here’s my scene tree and signal connections, everything appears to be connected properly

Is the Area2D a thin barline?, and/or is the body moving relatively fast? Wondering if the collision gets missed because the physics sample rate is too low to catch the collision consistently.

Is the body actually in group “line”?
I would put a breakpoint on the if statement and see if it is accidentally filtering out the body.
Also check that the area monitoring is set to true.

I don’t see a problem in anything that you’ve already posted, so I’m guessing the problem is elsewhere.

  1. Would this print statement fire?
#one of my Area2D nodes - the CharacterBody2D is in the group "line"
func _on_end_measure_body_entered(body: Node2D) -> void:
    print("Triggered!") # Will this fire?
	if body.is_in_group("line"):
		movingLine.position = Vector2(59.0, -147.0)
  1. Are you sure you have set all the layers and masks properly? Could you double-check?
  2. Does your CharacterBody2D have a collision shape?

This, too!

Have you tried connecting it with:

func _ready():

Area.on_body_entered.connect(method_name)

Or have you tried double checking they are one the same collision mask?