isSensor not working with particleSystem

Hi, I have the following main.lua, which works as expected, i.e. the particle bounces off the circle and two events get triggered (began and ended). If I un-comment line 12 to turn the circle into a sensor, then the particle will pass through the circle, but no events will be triggered. Even if I change line 9 from {radius = 30} to {radius = 30, isSensor = true} it will not trigger any events. My build version: 10.18.10.3408 / 2016.2828

local physics = require( "physics" ) physics.start() local function onRingCollision(self, event)     print "event triggered" end local sensorRing = display.newCircle(100, 300, 30) physics.addBody(sensorRing, "static", {radius = 30}) sensorRing.particleCollision = onRingCollision sensorRing:addEventListener("particleCollision", sensorRing) -- sensorRing.isSensor = true local particleSystem = physics.newParticleSystem {     filename = "particle.png",     radius = 3 } local particleParams = {     flags = {"water", "fixtureContactListener"},     x = 90,     y = 100 } particleSystem:createParticle(particleParams)

Tried every tweak I could think of, with nil results.  I note this historical comment:
 

I’ve tried using a physics body as a sensor to detect particle locations and velocities but sensors don’t generate collision events with particles.

Though I was unable to see why that has to be true. If it is true, it would be nice if it were documented here.

Hi ronburk, thank you for your reply and for confirming that it is indeed not possible. Bummer I didn’t find that thread when I looked for it, could have saved myself a lot of tinkering around. It is a shame that there is no mention in the documentation of it either, I find they are usually quite good with that. Just not in this case. I’m not sure if it’s a technical reason why sensors won’t work with particles, but I guess I’ll have to work around it somehow.

Hi @ronburk, @hmhm,

Let me investigate this and see if it can be fixed, and if there’s some internal reason why not, I’ll clarify this in the documentation. Thanks for bringing it to my attention.

Brent

@brent, thanks for looking into this for us!

Tried every tweak I could think of, with nil results.  I note this historical comment:
 

I’ve tried using a physics body as a sensor to detect particle locations and velocities but sensors don’t generate collision events with particles.

Though I was unable to see why that has to be true. If it is true, it would be nice if it were documented here.

Hi ronburk, thank you for your reply and for confirming that it is indeed not possible. Bummer I didn’t find that thread when I looked for it, could have saved myself a lot of tinkering around. It is a shame that there is no mention in the documentation of it either, I find they are usually quite good with that. Just not in this case. I’m not sure if it’s a technical reason why sensors won’t work with particles, but I guess I’ll have to work around it somehow.

Hi @ronburk, @hmhm,

Let me investigate this and see if it can be fixed, and if there’s some internal reason why not, I’ll clarify this in the documentation. Thanks for bringing it to my attention.

Brent

@brent, thanks for looking into this for us!

So whats the verdict on this? Is the isSensor not suppose to work, or impossible to work with particles? I ask because it seems like I can use that functionality right about now. I need to detect a collision begin/end with a particleGroup and a wind vent (rectangle) and handle my own physics instead of having them collide like mad.

Hi @kevinlboehme,

I just asked the engineers about this.

In the meantime, is your vent aligned straight vertically or horizontally? Or is it set at an angle? If the former, you could use the “object:queryRegion()” function instead of sensor rectangle. If it’s angled, you could draw two rays using “object:rayCast()”. In both cases, you could detect collision with that region or line and then send your particles flying off in whatever direction as if wind was blowing them.

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

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

Best regards,

Brent

I had planned on angled rectangles but I will look into both options. Trick is getting both a collision began and collision ended callback. Do those 2 options support began/ended?

Seems that is what’s needed for the wind tutorial I am following:
https://coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/

So whats the verdict on this? Is the isSensor not suppose to work, or impossible to work with particles? I ask because it seems like I can use that functionality right about now. I need to detect a collision begin/end with a particleGroup and a wind vent (rectangle) and handle my own physics instead of having them collide like mad.

Hi @kevinlboehme,

I just asked the engineers about this.

In the meantime, is your vent aligned straight vertically or horizontally? Or is it set at an angle? If the former, you could use the “object:queryRegion()” function instead of sensor rectangle. If it’s angled, you could draw two rays using “object:rayCast()”. In both cases, you could detect collision with that region or line and then send your particles flying off in whatever direction as if wind was blowing them.

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

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

Best regards,

Brent

I had planned on angled rectangles but I will look into both options. Trick is getting both a collision began and collision ended callback. Do those 2 options support began/ended?

Seems that is what’s needed for the wind tutorial I am following:
https://coronalabs.com/blog/2013/02/19/more-physics-tricks-explained/