0 votes

Even though I am using Godot 3.1-alpha, I don't think it is related since I had a similar problem in Godot 3.0.

I want to create a giant grid, made out of hundreds of chunks which are also made out of 100 cells each.

I opted for this design to improve performance, only the chunks visible on the screen are rendered.

At 225 chunks which represents ~22k cells, the game does not start and print constantly 'Object was deleted while awaiting a callback' in console.

This is how I instantiate a cell, in a for loop:

var cell = Cell.instance()
$cells.add_child(cell)

Chunks are instantiated in a similar manner.

I have a map scene where the packed scenes are loaded:

var Chunk: PackedScene = preload("res://Chunk.tscn")
var Cell: PackedScene = preload("res://Cell.tscn")

Chunks are created in this scene, the Cell packed scene is then given to the chunks once created in order to instantiate the cells.

I think that the problem is related to my implementation and not to Godot itself.

I would like some help, thanks.

Edit:

It looks like that the problem was related to the size of the message queue. By increasing it, I managed to instantiate 40k cells.
Though I doubt that it is a proper solution.

in Engine by (26 points)
edited by

I'm not sure what's going on here, but I can say 22K is probably way off the charts. Nodes are high-level objects, which means there is a limit of how many you can create at once without running into performance/memory issues. To go beyond, a more low-level or specific technique needs to be used, or simply not instanciate nodes that are too far away.

The error message is printed for statistics, maybe it's not directly related to your game but rather the debugger struggling with all the nodes? Also make sure to disable "Remote scene tree" otherwise it's going to choke for good.

What is in your Cell.tscn?

First of all, thank you very much.

Where is the "Remote scene tree" setting?

My Cell.tscn is made of 1 Node2d and 1 Sprite.

I think that the problem is that I don't know what the "message queue" is and what it does. That's why I'm having a hard time finding a solution.

I'm pretty sure that all I have to do is not build the scene in a single tick. I should try to only load a limited number of chunk per tick to not exceed the default message_queue limit. Because performance wise, it runs at 60 fps without any issue with 40k cells, so I think it's good.

Please log in or register to answer this question.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.