Madclaws

How to do burst particle effect.

Recommended Posts

Hi guys,

A babylon noobie here ,I am trying to get a simple burst particle effect like this https://phaser.io/examples/v2/particles/click-burst.

But sadly i could only do this much .https://www.babylonjs-playground.com/#5EGWMF#51(on colliding with first cube ,i should get the effect like above link).There are so many params for particle system to tweak.

Thanks.

Share this post


Link to post
Share on other sites

@Sebavan

Thanks for that tip.Is there any way such that when the first box hits the third box,the same particle animation should run at third box's position.
What i am doing is ,setting targetStopDuration to 1 and then on hitting third box i am calling particleSystem.start() again .But that's not working.

Modified PG link below

https://www.babylonjs-playground.com/#5EGWMF#57.

Thanks.

Share this post


Link to post
Share on other sites

@Madclaws I took a look at your playground and added a couple of things for debug. The first was to play the particle system on key press (spacebar) so that I don't have to rerun the scene every time to see what is happening. The second is that I commented out your manualEmitCount line as that will never allow more particles to spawn than the ones it spawns. It essentially says "emit only X particles all at once" which is why when you call start again nothing happens. You've already hit your particle limit on that system. I normally never use manualEmitCount just because of that limitation unless I am instantiating a system to be destroyed right after it's done. If you want a system that hangs around that you can turn on and off, you want to couple a high emitRate with a low targetStopDuration. This will simulate a burst, but you can time the emitRate to give some more pleasing gradients of speed than you get with a burst. Now your particle system plays when you reach each point or when you hit space, but it looks like your code needs a little massaging because the second collision continues to happen even after the cube is gone. To fix this I added a second isDestroyed boolean to prevent the particle system from running again like you do with your first collision. Let me know if you have more questions! Take care.

https://www.babylonjs-playground.com/#5EGWMF#59

Share this post


Link to post
Share on other sites

@PatrickRyan

Thank you very much for explaining the solution in detail and for the tips about particle system.This is what i need.Thanks a lot.I have one question ,the images that i use for particles have alpha mask (obviously).But in game these alpha masks are visible .I tried different images but still result is same.Any clue regarding this?

Screenshot  attached.

particle.PNG

Share this post


Link to post
Share on other sites

@Madclaws, the most likely issue here without seeing a playground is you did not set a blendMode on your particle system. If a blendMode is not set the default is BLENDMODE_ONEONE which ignores the alpha of your texture for more performance in your system as there is no overdraw. To get alpha you need to use:

particleSystem.blendMode = Babylon.ParticleSystem.BLENDMODE_STANDARD;

You can learn more about the available blendMode options at https://doc.babylonjs.com/babylon101/particles#particle-blending. To help you out a bit I converted the particle demos from our release video into a playground so you can dig in and play with the code to see how we normally set up particle systems. Make sure you focus on the canvas (click on it) and press space bar to iterate through the systems. I usually set up demos like this so I have control over repeating the system so I can evaluate the interactions of the particles and tune the variables. Let me know if you have more questions.

https://playground.babylonjs.com/#US7JSP

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.