_ready() called twice

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jhyatt
:warning: Old Version Published before Godot 3 was released.

Hi everyone,

I’m having an issue with my project which is causing the _ready() function to be called twice from one of my scenes. I added a print call in the ready function to confirm that it is actually being called twice.enter image description here

The output confirmed this.enter image description here

I’ve searched within Godot as well as online but have not been able to find what is causing this to happen. Is anyone aware of a potential source of the issue?

Additional info that may be useful: I am using Godot Version 2.1.3 and the _ready() function is only being called twice in a single scene object, not all of them.

Thanks for any info!

And the scene that have _ready() func called twice doesn´t call any NOTIFICATION_READY, or emitting any signal that can execute something that derivate in the unwanted _ready()? (I suppose that the scene that you have with 2 called _ready´s is not the scene that you don´t want to execute twice, there will be nonsense)

Unfortunately this issue is not remote fixable whitout the proyect, sorry. You have to follow the “spaggeti” (no offense) to find where the function is called twice. It does not look like a godot bug (it’s not almost certainly safe). Good luck with that.

But you should start by comment the code that call twice the wanted repeated _ready() and if this fix the issue, then you have the path to fix that.

807 | 2017-08-17 23:41

try commenting everything that is not the print statement(and the _ready()) aka the spawn_brick() line and check the results

rustyStriker | 2017-08-18 09:49

More information is needed, that node should be entering the tree twice to do that.
Maybe you have two instances of the same node somewhere too.

The error behind this may be not noticeable on Godot 3 (in case of being a single instance) because ready is called once per instance in that version.

eons | 2017-08-19 23:20

:bust_in_silhouette: Reply From: quijipixel

Are you changing the 2 ready node to another parent? If so, ready gets called everytime a node enters the root tree.

:bust_in_silhouette: Reply From: volzhs

There are similar issues on github.

and it’s fixed by - _ready() callback only happens once now, if you want to receive it … · godotengine/godot@f3f4a11 · GitHub

but it’s for master which is 3.0
I’m not sure 2.1.x have this fix too.