.Top_Image Side_MonitorsThe Gnomon Workshop
Particle Emission when Objects Collide, by Alex Alvarez

A commonly needed effect is the emission of particles at the exact location of object collision. For example, as a sword scrapes along a wall we may need sparks; As a boulder rolls down a mountainside we may need smaller instanced rocks and pebbles to appear; As a character walks along a dirtroad we would expect dust to appear at his feet.

Such effects require the ability to specifically determine particle emission at certain UV coordinates of the surfaces. This can be accomplished in a couple of ways: easy and involved. The involved technique requires us to use rigid body collisions, where the Rigid Solver has Contact Data turned on. This attribute allows some 'read-only' attributes to be accessible on the rigid body, such as 'contactCount' and 'contactPosition'. We could then query these attributes and use them with the 'emit' mel command to determine particle creation. But for those who prefer to avoid expressions, we are going to discuss a much simpler method using Softbodies.

Say we have a boulder which needs to roll down a hill creating dust clouds as it rolls. The boulder could be an active rigid body falling with a gravity field, while the ground is a passive rigid body. With this already set-up in the scene, select the rigid body boulder and turn it into a softbody. In the dialog box for 'create softbody', choose 'Duplicate, make copy soft', turn off 'hide original', turn on 'make non soft a goal' and set the goal weight to something greater than '.5'. At this point, what will be created in the scene, if you look in the Outliner, will be a duplicate of your boulder which has an associated Particle Object with particles at the location of each of the boulder's vertices. At this point select the 'shape node' of the duplicate 'soft' boulder and hide it. We only want to see the particles of the 'soft boulder', not the geometry. (we are not trying to make a jello boulder). If you play back your dynamic simulation, you will see the particles of the soft boulder trailing the original a bit due to the softbody goal weight value. When the boulder bounces off the ground, you should notice the softbody particles moving through the ground a little.

What we are now going to do is have the softbody particles collide with the ground plane. Select the ground and choose Particles/Make Collide. In the dialog box set the resilience and friction to zero. Then open the Dynamic Relationships editor and connect the softbody particle's collision to the ground plane. Playing back the simulation will now show the particles no longer going through the ground.

The next step is to select the softbody particle object and open the dialog box for Particles/Particle Collision Events. As you may now understand, by using collision events, we will have the softbody particles emit particles as they collide with the ground. So in the Collision events window, use the following settings: collisions should be set to 'all'. We want particles to 'emit', not 'split'. Then turn on 'random # particles' and set the max number to about 10. (you will raise or decrease this value later based on the desired effect). Set spread to about .7, Inherit Velocity to '0', and original particle dies to 'off'. Then hit 'create event'. If you now look in the Outliner, a new particle object will be there. This is the new particle object which particles are emitted into by the softbody particles when they collide with the ground. If you playback the simulation, you should now see particles appearing on the ground where the boulder collides. At this point on it becomes of matter of designing the look of the particles as well as their motion using fields, etc. Remember that you can also set these particles to collide with the ground, as well as the boulder (but you would also need to select the boulder and choose Particles/MakeCollide). The two main things you will be tweaking at this point will be the number of particles created by the collision event, as well as the goal weight of the softbody particles, based on the speed that the boulder is moving.

Our example uses two rigid bodies... but our scene could have as many objects as we like, where the above steps are applied to each. Remember that the collision events window allows multiple collision events to emit into the same particle object (the 'target particle' field in the collision events window).

If you are going to be hardware rendering your particles, by the way, you will notice that the softbody particles will be rendering as grey points. Just add an opacity attribute to them set to a value of '0', so that they will not be visible.

As a final note, this technique does not require us to use rigid bodies. In an example where a character's feet are creating dust, the ground would have 'make collide' applied, but it doesn't necessarily need to be a rigid body. Also, the foot itself doesn't need to be the object turned into a softbody... you could just skin a simpler object to the foot joints which is converted to a softbody. (and this object wouldn't be rendered, of course). So I hope you were able to follow along... its a relatively simple technique with a wide range of applications.

All Content Copyright ©2001, The Gnomon Workshop, Inc.