Jump to content

How to do burst particle effect.


Madclaws
 Share

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.

Link to comment
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.

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...