Area2D node's body_entered signal not emitting

Godot Version

4.4

Question

I am following this Ultimate Intro to Godot 4 video, and I have an Area2D node called Laser. The attached script, laser.gd, listens to Laser’s body_entered signal:

func _on_body_entered(body: Node2D) -> void:
	if body.has_method("hit"): #or if "hit" in body
		body.hit()
	print("laser entered " + body.name)
	queue_free()

This works fine most of the time. However, I just added a couple of new objects to the game that are not triggering this code when I fire a Laser at them. These are both instances of a custom type called GenericObject, which extends StaticBody2D:

extends StaticBody2D
class_name GenericObject

func hit():
	print("object")

Here’s a screenshot of one instance, Box:

Here’s the associated script (replacing the parent script inherited by default):

extends GenericObject
 
func hit():
    print("toilet")

For comparison, here’s another object called Gate with the same base type (no further inheritance in this case) and collision layer / mask:

Here’s the overall node hierarchy for the level I am testing:

When I run the level and fire a laser at the box, it goes right over. If I fire at the gate, it collides and triggers Laser’s _on_body_entered code. This is inconsistent with the tutorial I am following, in which the Box also collides with the laser. Can anyone explain the difference?

Cn you show how your lasers are set up?

Sure, here’s the node structure and collision:

Here’s the full attached script:

extends Area2D

@export var speed: int = 1000
var direction: Vector2 = Vector2.UP

func _process(delta):
	rotation = direction.angle()
	position += direction * speed * delta
	
func _on_body_entered(body: Node2D) -> void:
	if body.has_method("hit"): #or if "hit" in body
		body.hit()
	print("laser entered " + body.name)
	queue_free()
	
func _on_laser_lifetime_timeout() -> void:
	queue_free()

I reimplemented the base class and the objects that inherit from it, and now everything works fine. I have no idea what the error was originally, as only the names seem to be different on the new version of these nodes.