Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lizistorm | |
Old Version | Published before Godot 3 was released. |
Object pool is very commonly used in game development. But there is no build-in object pool in Godot. What’s the best way to make it?
Maybe need to create a module in C++? Any suggestion?
In a Reddit post, I read reduz’s post that Godot doesn’t need object pooling. I also like to know more about this. May be object pooling is not needed but in the case of instantiation we may need to create all instances at first and keep it in an array.
Someone from the dev team can explain.
vinod | 2016-03-29 05:22
Can’t find the post on reddit. Why Godot doesn’t need object pooling? Are the objects instanced in GDScript pooled by C++ code?
lizistorm | 2016-03-29 07:25
This is the Reddit thread
Reddit - Dive into anything
Also read the section under memory model
Core types — Godot Engine (latest) documentation in English
vinod | 2016-03-29 07:50
Checked the links. It solved the segmentation problem with the memory model. But not the time consume if a lot of instances need to be create frequently like bullets or small visual effects.
Maybe the time consume is very small so we can just ignore it?
lizistorm | 2016-03-29 10:27
There is no GC in gdscript so your game wont pause in random moments of time to free the memory, this is why there is no need for object pooling in gdscipt.
kubecz3k | 2016-05-02 10:17