Godot Version
4.5
Question
I’m wondering if anyone has had some success at advance handling particles in an abstraction that makes sense?
I’m looking for opinions on particle management. Pros and cons of setups.
requirements
- reusable root game object script (e.g. player, enemy, obstacle, etc.)
- expandable particle events for similar object classes, to maintain a level of artistry
- particle independence from game object.
- minimal code within game object. (will indicate a particle event, but does not care about how its managed )
- avoids inheritance, abstract classes are okay.
- performance: system pooling and reusable resources (this is secondary concern, but would be nice-to-have)
I have a reusable spaceship class script that will have various instances for the player and enemies. It is tied a scene that has some thrust effects currently. I now need to add some other effects like explosions and collision effects.
I could place particle systems in the spaceship scene and control events in the root script, but if i decide to use some special particles for one spaceship implementation it would mean diluting all instances with this one spaceship’s particle considerations into the same script.
finite particle set
To combat this I could abstract/categorize events into a finite set. ( death, collision, boost, attack, special, etc. ). But this to me seems limiting in freedom for object design.
detached particles
Another considerations, is that I will be adding and removing spaceships within the scene
but I would like particles to exist independently within the scene. I in some cases i could simply hide and deactivate parts of the ship class until the particles are finished before a queue free, but I feel like this will bloat the spaceship script with a bunch of asynchronous condition handling. One thing that could be alluring here is some resource optimizations and pooling of systems that can be reused.
For this, the obvious solution is to introduce a manager system to observe the ship for events and handle the particles, but I don’t like the idea of having to make such an abstraction to setup and listen for events from the spaceship class to handle the particles. In this case any expansion of particles would be lumped here instead the the game object script. (this doesn’t sound ideal but its a trade off for simpler dependent scripts )
particles in animations
I don’t have any of these yet, but I don’t know how well a manager system would work with an animation system for particular particles events. it would seem that particles would need to exist for previewing in the animation. so this would be a knock against the manager approach.
final thoughts
It seems like keeping the particles within the scene, for animations and convenience seems to be the best approach. Stomach the asynchronous handling within the script and potentially duplicate the script for potential edge case versions of enemy spaceships…
I have done some research for this but google conflates this with many entry level tutorials on particle systems, and not their management… What have you done to solve this issue? Do i just need to accept some level of duplication to maintain artistic freedom?