Area2d in instantiated scene behaves differently then local child node

Godot Version

4.2.1

Question

I have the following scene:
image

with the following script attached:

class_name Card_Debug
extends Control


func _on_drop_point_detector_area_entered(area):
    print("Card debug: area entered")

Here is my main scene:

image

with the following script attacked:

extends Node2D

@onready var card_debug = $Card_debug

func _process(delta):
	# Move the card_debug object slowly for testing so that the area2ds will collide
	card_debug.global_position.x += 1


func _on_static_area_2d_area_entered(area):
	print("Static area 2d entered")

The problem is that the “Card_Debug: Area entered” signal is being fired, but the “static area 2d: Area Entered” signal is not. I need both signals to fire.

It seems to me like this problem has something to do with the Card_debug/DropPointDetector being defined in the “Card_Debug” scene rather than being a child of the Card_debug instance that is defined in the main scene. If I manually create a node that has the same structure as the Card_debug scene, then both signals work correctly. For example:

image

extends Node2D

@onready var test_control_obj = $TestControlObj

func _process(delta):
	# Move the object slowly for testing so that the area2ds will collide
	test_control_obj.global_position.x += 1


func _on_static_area_2d_area_entered(area):
	print("Static area 2d entered")


func _on_test_area_2d_area_entered(area):
	print("Test area 2d entered")

with this as my main scene, both signals fire properly.

if you change the Card_debug type to Node2D, will it work?
it does seems to be the issues, because you mix control type and Node2D type
could be also a godot bug

I also tested this out in Godot 4.2.2 as well and get the same behavior.

Thanks for the idea. But unfortunately, changing it to a Node2D does not change the behavior.

Ugh, of course it was something really simple. I forgot “monitorable” and the whole “behavior seems different in an instanced object” was just a red herring. Thanks for the help.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.