Particle kill field for Maya

by Mike Rhone

 

I’ve been using Houdini for the last few months and I realized that it’s been a while since I’ve posted a good trick for Maya particles, so here is a hack I’ve had in the toolbelt for a while. I call this the Maya kill field.

 

This technique works with both nParticles and regular oldschool particles. In this example I’m using basic emitter and nParticles and have turned on the nucleus gravity for the system. I press play and I get a simple system like this:

 

 

 

 

 

 

 

 

 

Maya doesn’t have any such thing as a ‘killField’, so were are going to hack one using a uniform field node. Select the particles, then create the uniform field. Rename the uniform to killField. Set these settings:

Magnitude = 0.001

Attenuation = 0.0

Direction = 0.0, -1.0, 0.0

Volume shape = cube

 

 

When you have the particle selected and you create a field in Maya, the field is automatically connected to the particles. Now that the uniform field is created, scale it up in the scene so it is underneath where the particles are falling as I’ve done here:

In the particle attibute editor, change the lifespan mode to lifespanPP.

 

 

 

 

 

 

 

 

 

A bit of back story. When you connect fields to a particle system in Maya, a hidden particle attribute is created called inputForce. Every field that gets attached to a particle system creates one of these attributes. Because this is the only field in this scene, this attribute is called inputForce[0]. If you already have other fields in your scene this field may be inputForce[1], inputForce[2] etc.

 

 

 

 

 

 

Now that we understand that, lets create a particle expression to tell Maya what to do with this killField. Open the attribute editor for the particle system, right click on lifespanPP in the per particle (Array) attributes section and choose ‘Creation expression’. Now add this expression:

if (mag(inputForce[0] >= 0.0001))

{

lifespanPP = 0.0;

}

 

 

 

 

Click Create. Now copy that expression (CTRL+C) , then click on the ‘Runtime before dynamics’ radio box. Paste the expression in there as well. Click Create.

 

 

That should do it! Press play and you should see the particles disappear as soon as they enter the ‘killField’. Now if you want to have a setup that kills particles that are outside of the killField volume, turn volume exclusion ON on the killField.A bonus to this method is that because we are doing this via particle expressions and fields it is many magnitudes faster than using a collision event to kill particles.

Download the demo scene

Limits:

Now I did say this was a hack. One problem with this method is that the particle is killed the frame after it enters the kill field. This is because the particle needs to be in the kill field before it can affect it. Scale the field up or down as needed. For the kill field to work it has to have a very small amount of affect on the particles. I have found a uniform magnitude of 0.001 is usually so negligible it won’t be noticed.

Feel free to leave comments, questions or suggestions…!

–Mike Rhone

 

Creative Commons Licence This tutorial is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.