Printing out objects' instances give different types

Hello, I’ve got a curiosity: in the scene that I’m testing there are 3 people planting vegetables, everything is working fine, but trying to print the instance of the object that they are planting I get this kind of output:

@Node3D@15:<Node3D#708636051212>
@Node3D@14:<Node3D#698771048238>
Vegetable:<Node3D#692412483349>

why one instance is recognized as a Vegetable object while the other 2 as a generic Node3D?

The name is “Vegetable” the other two are anonymously named; all three are type Node3D.

Name:<Type#Address>

1 Like

Then the question is, as all of them are instantiated and spawned in the exact same way, why one is named Vegetable and the others @Node3D@?
I’ve just tried to restart the scene a few times planting 9 vegetables, one time 2 were printed with the name Vegeteable and 7 @Node3D@, 4 times the ratio was 1/8.
Why not all Vegetable or all @Node3D@?
I suppose this is not an issue, I’m just wandering the reason.

Node siblings cannot have the same name, Godot will use anonymous names for newly added nodes unless you use add_child’s second parameter “force_readable_name” but that is more expensive and rarely needed.

2 Likes

Got it, that makes sense, thank you.