• Godot Help
  • Can I attach a script to a node inside a .tscn not added to scenetree yet?

I ask because attaching the script after the scene is added won't activate the _ready or _process functions.

Alternatively, perhaps there is a way to restart the script after it is attached?

  • xyz replied to this.

    Shadowphile Sure. Instantiate the scene, get the node and attach the script using set_script() before you do add_child()

      xyz
      awesome, so simple!
      I did need to attach to a subnode so I've had to resort to dynamically building up my scenes rather than ones I made in the editor.
      But it's all working as I want, hooray!
      thanks