Emitter or Particle Tutorial?

Hello,

I’d like to make a rain effect for my game and I imagine I would do that with a particle system or something to do with emitter but I don’t know where to start. Are there any tutorials for this? The only ones I can find are for paid add-ons - surely it isnt that difficult? 

Try Google… https://github.com/vsergeyev/Rain/blob/master/Rain/rain.lua

Well I did try just bouncing up and down in front of the monitor singing the happy song but in the end I did use google.

I found that site. The code is outdated and I couldnt get it to function.

lol!!!   BTW, the code works fine and I use it in my app

Hi @Atrag,

Particle emitters are pretty easy to configure. Probably the best place to begin (for free) is to download our “EmitterViewer” sample project (it’s also bundled with the Corona application within SampleCode>Graphics).

https://github.com/coronalabs/samples-coronasdk/tree/master/Graphics/EmitterViewer

This sample contains a wide variety of emitters which are controlled by their respective JSON configuration files. If you find one you like, you can modify its behavior according to our EmitterObject documentation, adjusting values in the JSON file until you get the effect you like.

https://docs.coronalabs.com/api/type/EmitterObject/index.html

Hope this helps,

Brent

@Brent… Replicating rain is difficult in a particle emitter, I did try.  Particle emitters work great for source point animation like fires, etc. But they are not good for ambient weather effects which would need many hundreds of emitters as speed becomes a real issue.

Although if you have an example that can produce ambient weather effects I would be interested to see!

For example rain falling from a cloud? I would just “spread out” the emitter into a line/field emitter (not point) and then have drops falling randomly from it.

Wait… there are emitter types that aren’t point?  Oh that’s new…  goes of to investigate this.

@Brent again, I missed the memo.  Wish you guys would shout louder about new features!

Well, it’s sort of the same thing in that the emitter is “located at a point”. However, you can just tell the emitter to spread out any distance along the X or Y access from its location, and particles will start emitting from anywhere within that line or rectangular region. This is how people create particle effects like waterfalls.

Brent

Now if there was some way to create an isometric water effect - like an ocean mesh in Unity - I would be ecstatic!  I’ve tried and failed… Well, it worked great but not on device as it killed the frame rate.

Can you show me an example of what you mean? I might have some ideas (no guarantee, but I can at least see what you would like).

Thanks for your help… I will take a look at what you both suggested. Really all I want is a few cartoony droplets coming down from a moving rain cloud and the droplets impulsing whatever they collide with.

BTW, the code works fine and I use it in my app

It is the main.lua that didn’t work last time I tried it it seems. I guess I will adapt it to my own and see what it does. Guess I should sleep first though. Good night!

Ah… be aware @Atrag… built-in emitters are for visual effects, not for collision events like impulsing things the particles collide with. You may be able to use a third-party like “CBEffects” to actually add physical bodies to particles and then detect collisions on them. The library hasn’t been updated in awhile, but it was very popular back in the day and it should still work nicely:

https://github.com/GymbylCoding/CBEffects

Brent

You say “back in the day”… how do people usually achieve what I want these days? I thought of just having a function that is called every frame that randomly places a few drops of various sizes within the area of the cloud, grouping them, and apply gravity and a collisions event listener. Is there a drawback to doing it that way that I am not appreciating? I just read about emitters and felt I should use them!

This is my static water…

I would love to make it a bit more dynamic

(ignore the dodgy rain… playing with emitters)

Well, for what you want, emitters actually don’t seem like the proper solution. Emitters are ideal for beautiful visual effects like fires, flames, weather, etc. If you check out the sample I mentioned, you’ll see what I mean.

In your case, I would suggest using the LiquidFun approach which is physics-based. This lets you create physical particles which blend and meld together like water and other viscous substances… but they are not to be confused with “particles” from emitters (they are two very unique approaches).

There are demos of this too, if you’re interested in learning more.

Brent

That previous post is meant for @Atrag. :slight_smile:

Yeah I know… btw got a decent rain emitter working now.  Thanks!

Adrian,

Do you have a distinct “water layer”? Or is it all just isometric parts laid out in a single z-axis-ordered layer?

Yes, everything is on separate layers and these are grouped into a master layer for pinch/zoom/pan.

 masterDisplayGroup:insert(undergroundDisplayGroup) masterDisplayGroup:insert(waterDisplayGroup) masterDisplayGroup:insert(landDisplayGroup) masterDisplayGroup:insert(boatDisplayGroup) masterDisplayGroup:insert(pathDisplayGroup) masterDisplayGroup:insert(roadDisplayGroup) masterDisplayGroup:insert(carDisplayGroup) masterDisplayGroup:insert(trackDisplayGroup) masterDisplayGroup:insert(trainDisplayGroup) masterDisplayGroup:insert(eyetoolDisplayGroup) masterDisplayGroup:insert(graphDisplayGroup) masterDisplayGroup:insert(buildingDisplayGroup) masterDisplayGroup:insert(planeDisplayGroup) masterDisplayGroup:insert(overlayDisplayGroup) 

If it helps Perry has my source at the moment.

Maybe email is easier - adrian@spheregamestudios.com