Particle systems: Defining the vertices of an EDGE-type emitter


I was wondering if its possible to emit particles along an edge that has its vertices defined programattically.

For example, on click, instantiate a particle emitter with shape-type EDGE that has vertices at (0,0,0) and (1,1,2). In another case I want it to have vertices at (1,1.5,3), and (2,5,2)… etc. These are just arbitrary numbers. I want to be able to define the ‘mesh’ with each click.


I tried making a mesh with just two vertices but I got lost half way because I don’t know how to save a mesh prefab to be dragged into the ‘mesh’ box in the editor.

Personally, I would do this programmatically. You can call the Particle System’s Emit() function with a position specified, so… handle the emission yourself. Calculate a random point on the line and emit a particle there each frame, or more if you want. That way you don’t need to add a mesh or anything complicated.

We’ve just added support for particle systems to Emit from meshes that use the Lines primitive type, in 2017.3.

Just create a mesh, similar to here: Unity - Scripting API: Mesh

And then assign it to the shape module of your particle system.

(I’m posting this mainly as a hint for future readers, as 2017.3 is not yet out, as I write this!)