31

Heads-Up: This answer is outdated. Unity now supports point light particles natively. Please see this answer for full details. I'll leave post this here for anyone curious, or using old versions of Unity, or needing more manual control than the native method offers - just note that the native support is likely to be much more efficient and scalable than ...


28

Check out how PixelJunk Shooter did it (including simulation) in this presentation (PDF) at GDC2010.


19

This is a very broad question, but generally particle system features can be broken down into a few categories. Here are some general ideas for the sorts of things you might want to have. Emission features define how, when, and where particles are emitted. Continuously generate particles at a fixed rate, or generate a cluster all at once when triggered by ...


17

I admit I'm not aware of any ideal solution to this problem, so I'll describe a workaround that you may or may not be comfortable with: Render all of the particles using additive blending to a separate texture (or render target) with its background cleared to transparent. Render that texture (or render target) on top of your scene using alpha blending. I ...


16

You could try the old school fire effect. Let's say you store an 8-bit temperature value for each of your pixels. At each update: Feed the bottom line with random "hot" pixels (e.g. 200-256). For the others lines, all the way up: Each pixel gets a new temperature from the pixel below Times a random decay factor Pick your pixel colors from an 8-bit ...


12

George Duckett's answer is far more direct and really well presented if you need fully-simulated water in your game. For simulated shallow-water physics with minimal accuracy (less realism, more playful), this image gave me an incredible moment of clarity: http://www.patrickmatte.com/stuff/physicsLiquid/


10

What you want to do can also be thought of as reflecting the particle's velocity off the plane tangent to the circle at the point of contact. If you know the equation for doing that, then all you need to know is the circle's normal at the point of contact. To get that, all you need to do is normalize the vector from the center of the circle to the point in ...


10

Conserve your precious CPU/GPU cycles! You can inexpensively approximate rain (and rain splats) without using particles. The rain drops and splats don't even have to move or be aligned! Basically, randomly draw a bunch of the following sprites onto the screen: Source: bulletproofoutlaws.com (There's also a video of the final effect)


9

Have a look at premultiplied alpha. http://blogs.msdn.com/b/shawnhar/archive/2009/11/07/premultiplied-alpha-and-image-composition.aspx


7

From the video showed it just seems to be plain gravity to me. Most people think gravity makes things flying downwards, but looking at it from a more far away perspective it makes things fly in a elliptical or spiral kind of motion around the center. The particles are always accelerated towards the center, however fly beyond it until the gravity forces it to ...


7

You are on the right track. Typically for particle effects, flat triangles or quads are used for the particles as opposed to something like glutSolidCube. Often the quad are billboarded so that they are always oriented to the camera (so you never see them edge on). Having said that, there is no reason why you can't use cubes for your particles (apart from ...


7

You might want to look into fur shading technique. This is what I would use for this type of grass, since the shorter the grass is the better the performance (less layers). Basically it works by layering the same surface multiple times in small increments: You can also change the horizontal offset to make the grass look bent.


7

Light emiting particles is now a built in Unity feature in 5.5. Simply enable Lights in the particle inspector, throw in a reference to a light prefab (both point and spot lights work), and change the Ratio to 1. And voilà, particles that emit lights: Turns out, this is a rather optimized setup, running at 1500+fps on my rig even with maximum lights in ...


6

Found the answer in here. You can directly use the output of the editor in the API. It's really cool.


6

Just don't write to the depth buffer when rendering the particles. This will allow them to all be rendered and blended with each other. You should still perform depth testing though so that they can be properly occluded by geometry in the scene.


6

The particle system solution is likely the one you want as creating and maintaining 100+ sprites with varying positions and gravity is exactly what a particle system does. Only it will handle object re-use for you automatically which will help make it as efficient as possible. Just create a line emitter that covers the entire width of your viewport. ...


6

It looks like you haven't set ps to the correct type (it should be a particle system). Try something like this: GameObject prefab = Instantiate (Prefab, myPosition, Quaternion.identity) as GameObject; ParticleSystem ps = prefab.GetComponent<ParticleSystem> (); bool checkIfPSPlaying = ps.IsAlive ();


5

As with all other "preferable" or "best" approaches, it depends on what your end goal is. For example, if you associate the particle list with it's emitter, this means that the emitter must continue to live until the particles have all decayed away. So your emitter needs to have more state. It needs to know whether it should be actively emitting more ...


5

Using additive blending order doesn't matter: glEnable(GL_BLEND) glDepthMask(GL_FALSE) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) DrawParticles(); // Now turn depth masking on and blending off, so state is unchanged. glDepthMask(GL_TRUE) glDisable(GL_BLEND) This assumes that your sprite texture has a transparent background.


5

Grant Kot has put some of his fluid simulation code up on Github with implementations in both javascript (canvas) and C++ with OpenFrameworks: https://github.com/kotsoft He has a few demos up on his youtube account: http://youtu.be/HqWheJSEiaw I have no idea how it works, but I know it runs fast and there's all sorts of variations to build with it. A good ...


5

The example image makes it much clearer what you want. "Contrail" probably isn't the right word for this; at my company we call it a "swoosh" but other people probably call it something like "sword trail", "sword slash" or similar. Anyway, the way to do this is basically to generate dynamic geometry, by recording the position of two points on the sword (...


5

First figure out the direction based on where the particle is in reference to where it came from (the explosion). Then you take the arc-tangent of that to get the angle. Vector2 direction = particlePosition - explosionPosition; float angle = Math.Atan2(direction.Y, direction.X);


5

Yeah, I would say go with a 4-vertex triangle stripped quad. If you are drawing large numbers of these triangle strips using the same color, and the same set of texture coordinates, you could do 1 of 2 things: 1) Send the 4 vertices for each object and store the color and texcoords in uniforms 2) "Hardware instancing"


5

I'm guessing you have 64 bit java installed. The ParticleEditor.jnlp fails to run on a 64 bit JRE. What you would want to do is: Download a 32 bit version of JRE. Here is the Oracle link for that: http://www.oracle.com/technetwork/java/javase/downloads/java-se-jre-7-download-432155.html Just make sure you select a "x86" version of the JRE from the list, ...


5

The general rule of thumb when drawing alpha polys is: 1 - Draw all solid polys first. 2 - Sort back to front if you can. The main reason for this is to ensure that the final colour produced by the blending equation is consistent frame to frame. I often don't bother with this step unless it is something provided by the engine and I can justify the extra ...


5

Create a new particle system In the general settings: "Start Lifetime" reduce a lot. The lower, the lower the length of the particle trail. In my example I am using 0.2. "Start Speed" to 0, so the particles don't move from where they were created. "Simulation Space" to "World" so the particles don't move when the parent moves "Emission": Controls the ...


Only top voted, non community-wiki answers of a minimum length are eligible