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)
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.
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.
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.
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.
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.
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.
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?
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.
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.
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?