I’m using a spawner for both entity types and was testing using a signal to spawn_destination.add_child(entity, true) for the ItemPickups (the entity gets passed via signal to function that adds it). The Enemy nodes are added directly from the spawner. My code works as I had hoped but I’m stumped at the non-unique ItemPickup names in the remote tree.
What… does this mean? Can I ignore this or is this a sign that I have porked something up somewhere?
This shouldn’t happen so I’d consider it an engine bug. Searching the issues on github, it looks that something like this was reported in earlier versions and fixed. Apparently not.
I’d suggest making a minimal reproduction project and reporting it.
Unique names are not required bur Godot tries to enforce them for siblings. Otherwise you may end up with two nodes having same node paths which has a high potential to cause bugs. Not sure what exactly you or op did to end up with same names, but you should take extra care to ensure that siblings don’t have the same names.
I’ll reduce my project down and upload it when I get a moment. I’d like to know what is going on as well as it feels weird to have identical-looking nodes.
I would say write code to get the child nodes of Pickups. Get the count.print ItemPickup object id. E.g. var child_id: int = child_node.get_instance_id() Maybe this will give you a clue.
That bug also looks annoying but I don’t think that causing this: both Enemy and Snowflake (renamed from “ItemPickup” in original screenshot here) nodes have terrible Remote Node2D: 38252053992 names in the Inspector but only Snowflakes are instantiating with non-unique names. If this was the cause then I would expect the Enemy nodes to also have non-unique names.
Didn’t got it reproduced in a single script, but found what’s causing it:
A scene gets instantiated, but instead of adding it to the scene tree after instantiation, one of their nodes adds itself to the scene tree (by calling an Autoload).
Example:
extends Node
@export var scene : PackedScene
func _ready() -> void:
for i in 3:
scene.instantiate()
# node in the instantiated scene:
extends Node
func _init() -> void:
Autoload.add_child(self, true)
I have found a good rule of thumb with Godot is never use _init() on first pass of a new object. There are a LOT of gotchas with it. Always use _ready() when you would use a constructor. Then, once your object is working, if you want to use _init() when stuff breaks, you will know it worked before, and what you changed.
There are so many things that Godot does under the hood with Nodes, and you need to have a good understanding of them before you treat them as you would classes in another language. Because they are not Objects, and people coming into GDScript often treat them as such. (I know I did.)
Also, I was kinda right. You were renaming the nodes, just didn’t know it.