particleCount is not accurate enough for counting collisions

I have a particle system that emits x amount of particles, but when I check intercept particle collisions in the OnParticleCollision and sum them up using GetSafeCollisionEventSize() the number of collisions is typically less then x. I make sure that particles have long enough lifetime so they will not expire before reaching the collider. Is this inherited limitation of the system or is there some setting or trick I’m missing.

Reason I’m doing this… player has a shield that is used to block fire. If player presses a button at the same time fire hits the shield I increment a bar of “captured flame” for a bonus. So a player that “captures” all the flame will fill in the bar completely. The issue is that I want to emit just enough flame to fill in the bar (no more or less), but with the problem described above I can’t be sure that enough particles will register as collisions.

Thank you for any suggestions you might have.

i’m not sure why some collisions are going missing… 2 ideas though:

  1. make sure collision detail is set to High in the collision module.

  2. try to use the trigger module instead, and see if that gives you the right numbers. you’d lose any collision reaction though. (eg bouncing off the shield, depends what you want visually)

Thank You for replaying. The detail is already set to High, but I did not try trigger. Will give it a go and update. Your message gives me the impression that this behaviour is unexpected? Then its possible I might be doing something wrong.

1 Like

yeah, if all the particles collide, the api should give you back the same counts as you emitted. so it’s unexpected.

but it’s hard for me to say more with only the info from the thread.

I figured it out. Thank you so much for the assistance. Much appreciate it.

In OnParticleCollision I was accessing the particle system particleCount property. My assumption (what got me) was that the particles that just collided would be excluded from particleCount value. It seems that they are not however. At the time of the OnParticleCollision call the particles that triggered this call are still considered as “valid” and part of the particleCount value. Once I adjusted for this I’m getting 100% particleCount to expected number of collisions. Again, thank you for getting me unstuck.

1 Like