I’m working on the project where I need to handle some graphic effects, like when you hit something or fire a shot.
So, I was thinking of using event entities like OnHit, OnShot, etc., to trigger these effects. It seemed like a good idea at first, but now I’m not so sure.
Handling particle effect in event based is best practice on ECS?
How do you guys think about this?
Unity has their AnimationEvents built into that, where you can tie them to keyframes of your animation. I almost used that. They have something in there called Beaviours, which give you some more control over when to run different scripts. You can make some generic scripts then that play a particle system you have in a field onEnter, or OnExit, things like that. I think there’s more options too. You can likely do something like get the length of the current aniamtion and play your particle system at 50% of the way through it, if you didn’t want to use the keyframe route via events. I don’t really like that it’s string based, so I opt not to use it. Anyway, a few ideas. GL
Also I’d mention that we made a particle system pool which you can ask for certain vfx from anywhere, it’s a singleton. It’s pretty nice. Once they’re done, they go back to the pool automatically.
I’ve done something similar to what was shown in the DOTS Galaxy Sample, using VFX Graph. It removes the need to manually make a managed particle system pool and keeps your hierarchy clean. To make sure the VFX always render regardless of the position on the world, and to avoid having a huge bounding box, I just set the bounds center of the VFX System to match the main camera position.
If you can use VFX Graph for your target platform, I highly recommend it over the standard Particle System.