Hi, me again.

Making a mobile game where the player is an apple falling out of a tree and has to dodge branches to get to the bottom. There are 4 variants of the branches that need to spawn randomly. To do this I scripted an area 2D off-screen to queue_free the object and spawn a new one randomly from an array once it collides with it. It works great at the first couple passes but for some reason after that 2 of the branches in the line will just pass through the Area2D and a new one won't be spawned. Eventually, after working correctly a few more times, the rest will also be ignored and no more branches come up. Kinda stumped on this one. Hope that made sense. Thanks 🙂

Here's the code for the Area 2D that deletes and spawns a new one:
`extends Area2D

var branchLarge1 = preload("res://branch_large.tscn")
var branchMedium1 = preload("res://branch_medium_1.tscn")
var branchLarge2 = preload("res://branch_large_2.tscn")
var branchMedium2 = preload("res://branch_medium_2.tscn")

var branches = [branchLarge1, branchMedium1, branchLarge2, branchMedium2]

func respawn():
branches.shuffle()
var branch_instance = branches[0].instantiate()
branch_instance.position = Vector2(0,1472)
get_parent().call_deferred("add_child",branch_instance)
print(branch_instance)

func _on_area_2d_body_entered(body):
if body.name == "branchLarge":
body.queue_free()
respawn()
if body.name == "branchMedium1":
body.queue_free()
respawn()
if body.name == "branchLarge2":
body.queue_free()
respawn()
if body.name == "branchMedium2":
body.queue_free()
respawn()

P.S. I know having multiple if statements for each branch type isn't the best way. I tried groups but for some reason, it didn't work so I tabled the issue for now. It works the same when I had just 2 branch types so I don't think it's the issue.
`

    LamplightCreativeStudio When a new branch is spawned there's a possibility that a branch with the same name already exists. In that case Godot will add a suffix to the name and all your ifs will be false for that scene as the name will not match anything you're checking for. Monitor the remote scene tree at runtime to see what's happening with the names. Btw I don't see any need for name checking at deletion.

    LamplightCreativeStudio Right, chances are that the node names will eventually not just be a simple "branchLarge". Either look at the remote scene or add a print(body.name) to your signal handler.