I’ve been recently moving all of my projectiles over to use an object pooling plugin from the marketplace but have some questions about general pooling best practices and how to set things up for my specific needs.
I have a number of different types of projectiles in my game (some w gravity enabled or not, homing or not, each has a unique appearance, emitter, speed, etc). All said and done, maybe 25 unique projectile types.
Generally speaking, when setting up object pooling, is it more performant to have one large pool with a single ‘master projectile’ whose appearance/movement/speed/etc are defined as it’s picked from the pool or is it better to have multiple pools, one for each unique projectile type, which don’t require me to make any changes to the projectile before launching?
Speed wise, it would be slightly faster to have multiple pools - but I don’t know if it would give you enough increase to warrant the extra complexity of maintaining multiple pools in your blueprints.
The pooled projectiles could use StaticMesh Instances which would just be a pointer - so it’s down to just a few settings for the mechanics of the projectile, not a lot to set in a “global pool object”…
Hrmm thanks. I agree on the complexity of managing multiple pool sizes… I’d really like to avoid being in that business, if at all possible. Even after optimizing (upon all the currently equipped weapons/ammo types), I’d most certainly end up carrying a higher number of total objects across all the pools.
I may just have to build it out both ways and calculate exactly how much my ‘projectile config’ step costs me. I’m still hoping to avoid that, but at least I would know the next move from there.
If you do decide to split up your projectiles into groups then put them in a hashmap to have it as quickly accessible as possible.
So you could have a pool with a string key and a TArray of objects to be pooled.
Having a single UOBject pool is probably a bad idea because retrieving a specific class type might have to itterate over many classes that do not qualify or a already active.