- Edited
I am developing using godot 4.0.3.
I have written code that uses Area3D to perform a screen transition when the player enters the Area3D area.
The Area3D is in SceneA and it receives the signal of body_enterned and transitions to SceneB.
I used the code remove_child(SceneA)/ add_child(SceneB) for the transition.
I did not queue_free() SceneA because I want to resume it immediately.
While manipulating the Player in SceneB, I noticed that the Area3D placed in SceneA was sending a signal.
Since the Node in SceneA is remove_child, I am confused by the counter-intuitive behavior.
I am wondering if this is due to the spec.
If so, I would like to know what other best practices there are for switching between 3D scenes.
Thank you.
I can reproduce it with the following code (Player is something that can be manipulated)
In this case _on_area_3d_body_entered is called many times.
extends Node3D
@onready var _area := $Area3D as Area3D
func _ready():
_area.body_entered.connect(_on_area_3d_body_entered)
func _process(delta):
pass
func _on_area_3d_body_entered(body: Player):
if not body is Player:
return
print('entered!')
remove_child(_area)
print('removed!')