OnParticleCollision - Access particle collision location?

So I thought of an algorithm to make blood splat effects on the ground using OnParticleCollision, basically when the enemy is hit, particles will come out, and as it collides, a decal will appear on the place it collides (the ground) However im having some major issues…

  • I dont know how to instinitate a decal/gameobject that is in the same position of the particle collision.

-For some reason, my script will detect the collision 50 times in 1 second, the code is

function OnParticleCollision(){
print("works!")
}

and it will print “works!” 50 times every 1 collision…

Can anyone help me out?

PS. Ive seen the awesome http://forum.unity3d.com/viewtopic.php?t=2668, but doesnt seem to help in my situation for it will only splat where the mouse is clicked…

Bump^.<

The only way to tell where the particles are is to look through the emitter’s particles array. This doesn’t give any information about which particles have collided, so you need some other way to determine when that has happened.

So theres no real way of telling what position the particle has collided? What about if i retrieve the position of the particle, and once it collides, the splat will appear at the same position of collision? Im just not sure how to retrieve the position of the particle…

If there’s only a single particle, then logically the position of the particle at the time of it’s collision would be the point of collision. The following page of the documentation will give you an example of how to retrieve an array of struct Particle.

http://unity3d.com/support/documentation/ScriptReference/ParticleEmitter-particles.html

As far as receiving 50 collision events for each particle, if you look at the particle system documentation you will see values for that affect particle energy and velocity when they hit a world collider.

It’s quite possible your particle is still living through multiple frames when it collides.

Got it to work, thanks for the help everyone :stuck_out_tongue: