particle damage

hi everyone. i have a cube which shoots out particles. i want to make it so that when the particles touch someone tagged enemy, it does damage to it.

here is my enemy health script

var Health = 100; function Update() { if (Health <=1) { Destroy (gameObject);

}

}

function OnCollisionEnter(rigidbody) { Health -= 10; }

this makes it so that when a bullet hits me i get damaged but i need to add particles to this as well which i have no idea how to do at all. any help will be really appritiated.

Particles aren’t rigid bodies, they call the function OnParticleCollision on the object they hit, so try :

function OnParticleCollision () {
	Health -= 10;
}

thanks it realy helped. do you know how to go about making different particle effects do different amounts of damage?

thanks

Make the different particle effects into different prefabs and make the amount of damage dealt by the script a public var and change it on each prefab.

Of course, that would mean you would have to attach the script to the particle systems and change the script so that it’ll deal damage if it collides with an Enemy tagged GameObject.