4.6
Instantiation is one of the biggest hitches when adding a scene. It could technically be threaded. Does godot have any way to do it?
4.6
Instantiation is one of the biggest hitches when adding a scene. It could technically be threaded. Does godot have any way to do it?
In what way do you mean? You can instantiate scenes on a separate thread, but I’m not sure how much sense it makes to instantiate individual nodes on threads as combining them would have to be done on the same thread
Yes and no. You can certainly instantiate objects on a separate threads, but add_child() will still cause hiccups just the same as it will in a single-threaded instantiation.
EDIT:
I have a game that does all of its instantiation on separate threads, and it works extremely well during the load phase, but sometimes hiccups at the add_child()phase. There seems to be no way around it as of now.
Hiccups which are caused by the threads having to join to do this:
Admittedly, I’m not a professional game developer, but as a programmer I dare predict that even in game development introducing your own multi threading is a premature optimization that is more trouble than it’s worth in most cases.
However. If you build really big scenes and have interesting content that loads fast for a player to enjoy then sure preloading those big scenes in a background process makes a lot of sense… But is it the first thing you worry about when working on a project?
Agree strongly
Or just use object pooling.
add_child.call_deferred(new_node)
bro i had to fully reimplement instantiaton of a scene in GDSCRIPT, so i could do it in parts cuz godot has no way to do it why does it have to do it all at once??
If you do it in parts like this starting with the children buildling to the root you cant access siblings in your ready code but you can load large levels over time
Breaking up your scene in multiple subscenes was not an option?
Each subscene would have been a direct parent to the nodes that would have needed access to their siblings..
I can imagine you had a hierarchy that could not have withstood some rearranging of the nodes either.
Just assuming here.
I generally instantiate and spread out over several frames as you can often control when you transition into when certain meshes need to be added. Same way I also remove stuff staggered over several frames, by just adding them to a queue. You can then tweak how many you add/remove in one single frame until you get into frame rate drops.