MonoBehaviour.OnParticleCollision Manual     Reference     Scripting  
Scripting > Runtime Classes > MonoBehaviour

function OnParticleCollision (other : GameObject) : void


OnParticleCollision is called when a particle hits a collider.

This can be used to apply damage to a game object when hit by particles. This message is sent to all scripts attached to the WorldParticleCollider and to the Collider that was hit. The message is only sent if you enable sendCollisionMessage in the inspector of the WorldParticleCollider.

// Applies a force to all rigid bodies that are hit by the particle.
function OnParticleCollision (other : GameObject) {
var body = other.rigidbody;
if (body) {
var direction = other.transform.position - transform.position;
direction = direction.normalized;
body.AddForce (direction * 5);

OnParticleCollision can be a co-routine, simply use the yield statement in the function.