![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Nonken |
So for my game i’ve got one main scene where i then instantiate the other scenes to it (like the main menu and all the levels) and the player scene is instantiated in the other scenes (not through code) that get added to the main scene. Would the _ready() function on the players script get called when i swap scenes (levels)? To clarify, if i remove the current levels scene and add another one that also has the player scene in it would the players _ready() function get called again?
I believe the _ready
function would be called again, yes. However, if I understand your situation correctly, it’s important to realize that although the _ready
function in the player’s script will be called multiple times, from a player instance point of view, individual player instances’ _ready
function will only be called once, since you are creating multiple player instances assuming each stage defines it’s own player.
I believe that moving (via code) the player from one level to the next would not trigger the _ready
function to be called twice, but I may be wrong on this point.
godot_dev_ | 2022-08-05 20:37
A tip, for future - for this and other similar questions.
Just throw a print statement in ready()_
and try it. Do you see your message output each time you load a new scene? Or, similarly, set a debug breakpoint in _ready()
. Does it get hit each time you load a new scene?
jgodfrey | 2022-08-05 21:31