Question on LiquidFun particle "quantity"

Hey!  Let’s say I have a bucket full of LiquidFun particles (fluid), and some of it spilled due to bucket impacts…    

How would you guys go about determining the approximate amount of liquid left in the bucket in terms of percentage?  Or, shall we say, can we actually keep count of the total number of active particles at any time?

Cheers!

Santi

Hi Santi,

Did you try to query the particle count of the particle system?

https://docs.coronalabs.com/api/type/ParticleSystem/particleCount.html

This should return the current count of “alive” particles, but of course, that doesn’t necessarily mean that particles which fall outside of the bucket instantly become “dead”. You’d probably need to use particle collision to explicitly remove particles which fell out of the bucket (by detecting their collision with an invisible offscreen sensor or something), so that those particles would no longer be counted as alive.

Brent

Good idea Brent,  but now I don’t want to ‘destroy’ the spilled particles so the mess shows up  :)

I guess I’d do your suggestion to use invisible sensors outside (and near) the bucket to tag particles as “spilt” when they make contact with it, or something like that.

Thanks

Santi

Could you look at it the other way and have a sensor in the bucket?
Then you could count the number of particles still in contact with the bucket sensor.

As @Strange Flight suggests, that might be the best way. Keep a separate count (variable) of the number of particles currently in the bucket by using collision detection, and when a particle leaves the sensor region (inside the bucket), subtract one from the count.

Brent

Great suggestion guys!  @Strange Flight thanks for the idea.

Hi Santi,

Did you try to query the particle count of the particle system?

https://docs.coronalabs.com/api/type/ParticleSystem/particleCount.html

This should return the current count of “alive” particles, but of course, that doesn’t necessarily mean that particles which fall outside of the bucket instantly become “dead”. You’d probably need to use particle collision to explicitly remove particles which fell out of the bucket (by detecting their collision with an invisible offscreen sensor or something), so that those particles would no longer be counted as alive.

Brent

Good idea Brent,  but now I don’t want to ‘destroy’ the spilled particles so the mess shows up  :)

I guess I’d do your suggestion to use invisible sensors outside (and near) the bucket to tag particles as “spilt” when they make contact with it, or something like that.

Thanks

Santi

Could you look at it the other way and have a sensor in the bucket?
Then you could count the number of particles still in contact with the bucket sensor.

As @Strange Flight suggests, that might be the best way. Keep a separate count (variable) of the number of particles currently in the bucket by using collision detection, and when a particle leaves the sensor region (inside the bucket), subtract one from the count.

Brent

Great suggestion guys!  @Strange Flight thanks for the idea.