Hi all, quick question but I'm not finding any info online anywhere. I've got an autoloaded script that spawns in player characters, but when I spawn the player it doesn't show up in the map and I can't even run the _ready() code.

I'm suspecting that it's because the player isn't set to the child of the root node, but I'm not really sure.

So if I am instantiating a player object using an autoloaded script, do I need to set it as a child of a root node? If so, how do I actually set that? I can't find good info for setting an object to a child of a specific node.

  • xyz replied to this.

    CorvaNocta You need to put instantiated node(s) into the scene tree by parenting them to any other node that's already in the tree. It doesn't have to be the top/root node. It's typically done by calling add_child() method on the parent node.

    parent_node.add_child(newly_instantiated_node)

    Doing this will automatically execute _ready() in the child node and all of its descendants.

      xyz it's always the easy stuff that alludes me lol. Thanks for the info!