0 votes

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!

asked Aug 17, 2017 in Engine by Jhyatt (14 points)

And the scene that have ready() func called twice doesn´t call any NOTIFICATIONREADY, 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.

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

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.

2 Answers

0 votes

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

answered Aug 18, 2017 by quijipixel (685 points)
0 votes

There are similar issues on github.

and it's fixed by https://github.com/godotengine/godot/commit/f3f4a11cfb9767e1d691aec431dd2f1a87a31977

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

answered Aug 18, 2017 by volzhs (9,489 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.