Particles - UpdateFunction override the default behaviour

Hello, I should create a particle effect like that:
when the animation of the emitter is finished, all the particles quickly increase their speed, a bit like an explosion.
I’m trying to use the updateFunction, but I’ve discovered that it completely override the default behaviour of the particles, so when I apply an empty function all the particles “freeze” (don’t move anymore, don’t change color anymore, etc).
https://playground.babylonjs.com/#IQPBS4#15
Is there a way to retain the default particles behaviour, and “just” add a new one, a bit like a new per particle animation layer?
I know that this can sound a bit strange, talking about code, and for sure this could give performances issues, but otherwise I should first check each particle speed, color, etc, and write a very complex (for me) function just to realize a quite simple effect…
Many thanks!

1 Like

Here is a quick draft - https://playground.babylonjs.com/#IQPBS4#16
You don’t need to update the particle system, just change some properties like minEmitPower etc to tune as you like :slight_smile:

1 Like

Thank-you for your help labris,
but when the animation is finished the emitter should stop, and just the visibile particles should change their speed, a bit like this:

1 Like

Another thing to trying is using velocity gradients to speed up the particles at the end. I also changed the if condition to only fire once by checking if the particle system is already stopping before calling stop and adding the velocity gradients. :slightly_smiling_face:
https://playground.babylonjs.com/#IQPBS4#17

2 Likes

could always use the SPS and script up your own update function entirely for some billboarded quads.

Seems this is just matter of settings of speed and timeout. Here are two examples:

1 Like

Just to circle back and answer this part of the question, you can for example cache the original update function and call it at the beginning of your new update function like this. Haha the animation I added isn’t very good but shows how to add new updating behavior on top of the existing. :slight_smile:
https://playground.babylonjs.com/#IQPBS4#18

2 Likes

Wow… thanks a lot for all your reply!
Blake, your solution as expected increase a LOT the CPU requirement but it’s exactly what I was looking for.
P.S.1 the velocity gradient is for sure a good option, I have to give a look to this
P.S.2 It would be really nice to use GPU particles, but I’ve read that them can’t use mesh emitter, so I would not know how to use a baked animation to move the emitter along a path…

2 Likes

The documentation seems a little confusing here, but you can use the GPU particle system and still have it follow your mesh around like you want.

Here I copied the example GPU particle system from the PG in the doc and brought it into your PG for a starting place, using your mesh for the emitter and a sphere for the particleEmitterType. I think you can use it to create a similar effect as you had. :slight_smile:
https://playground.babylonjs.com/#IQPBS4#22

2 Likes