I have a New Game menu item that shows a new scene and I want to run a function at that point.
I tried using the ready() function in the scene but it seems the ready() functions for all nodes and child nodes run automatically when the program starts.
I tried connecting to several signals but I can't find one that runs only when a scene activates.
How do I do this?


I thought I had this solved but it turns out I did not.
I crossed posted to reddit.

6 days later

The ready() function for a node runs when that node is added to the scene tree. A node's children are added to the scene tree first: if B is a child of A, then B's ready() function is run before A's _ready() function.

I'm not sure what you mean by "a scene activates".

Well you are already running the code that shows the scene, you can place the code there, or call a function.

8 months later