Pre-collision event fires after collision

If you run the following code you will see that local precollision is dispatched after the global collision. Is this intended behaviour as it doesn’t make any sense at all. The whole point of PreCollision should be to happen pre - collision so that you could override the intended behaviour. Please advise if there are some workarounds. Thanks.

output:

onCollision: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2
box1.preCollision, with: box1, box2

[code]
local physics = require “physics”

physics.start()

local box1 = display.newRect(50, 50, 50, 50)
box1.name = “box1”
physics.addBody(box1, “dynamic”, { density=1.0 } )

local box2 = display.newRect(55, 250, 150, 150)
box2.name = “box2”
physics.addBody(box2, “static”, { density=1.0 } )

box1.preCollision = function(self, event)

print("box1.preCollision, with: " … self.name … ", " … event.other.name)

end

local function onCollision(event)
print("onCollision: " … event.object1.name … ", " … event.object2.name)
end

Runtime:addEventListener( “collision”, onCollision )
box1:addEventListener(“preCollision”, box1)

[/code] [import]uid: 21280 topic_id: 7511 reply_id: 307511[/import]

This is meant before the collision - began phase. [import]uid: 21280 topic_id: 7511 reply_id: 26601[/import]

I have in the past been working with Pre-collision events and had them behave the way I expected them to ( first pre-collision, then collision in the began phase ). I was using this recently to have a character pass through platforms from below, but I’ve updated to a more recent daily build and it seems I’m running into the issue above: my pre-collision events are firing after collision events on the same object.

Is this a bug that has been re-introduced? Or have I possibly messed up my code? ( I don’t think I’ve changed anything since it was working so I don’t think that it’s on my app’s end) [import]uid: 136876 topic_id: 7511 reply_id: 126131[/import]

If you run this in the recent builds you’ll see that the precollision event is firing after the collision event.

[code]
require “physics”
physics.start()
physics.setDrawMode( “hybrid” )

– The ground
local ground = display.newRect( 0, 0, 600, 30 )
ground:setFillColor(128,128,128)
ground.x, ground.y = 300, 400
physics.addBody(ground, ‘static’, { density = 1, bounce = .5, friction = .4 })

– The ball
local ball = display.newCircle( 100, 100, 30 )
ball:setFillColor(128,128,128)
ball.x, ball.y = 150, 0
physics.addBody(ball, ‘dynamic’, { density = 1, bounce = .5, friction = .4, radius = 30 })

– Ball Collision Event Handler
ball.collision = function(self, e)
print("Ball collision " … e.phase … “.”)
if e.phase == ‘ended’ then print(’ ') end
end

– Ball Pre Collision Event Handler
ball.preCollision = function(self, e)
print("**** Ball PreCollision.")
end

ball:addEventListener(‘collision’, ball)
ball:addEventListener(‘preCollision’, ball)
[/code] [import]uid: 136876 topic_id: 7511 reply_id: 126259[/import]

I have in the past been working with Pre-collision events and had them behave the way I expected them to ( first pre-collision, then collision in the began phase ). I was using this recently to have a character pass through platforms from below, but I’ve updated to a more recent daily build and it seems I’m running into the issue above: my pre-collision events are firing after collision events on the same object.

Is this a bug that has been re-introduced? Or have I possibly messed up my code? ( I don’t think I’ve changed anything since it was working so I don’t think that it’s on my app’s end) [import]uid: 136876 topic_id: 7511 reply_id: 126131[/import]

Filed a bug report: http://bugs.anscamobile.com/default.asp?17858 [import]uid: 136876 topic_id: 7511 reply_id: 126363[/import]

If you run this in the recent builds you’ll see that the precollision event is firing after the collision event.

[code]
require “physics”
physics.start()
physics.setDrawMode( “hybrid” )

– The ground
local ground = display.newRect( 0, 0, 600, 30 )
ground:setFillColor(128,128,128)
ground.x, ground.y = 300, 400
physics.addBody(ground, ‘static’, { density = 1, bounce = .5, friction = .4 })

– The ball
local ball = display.newCircle( 100, 100, 30 )
ball:setFillColor(128,128,128)
ball.x, ball.y = 150, 0
physics.addBody(ball, ‘dynamic’, { density = 1, bounce = .5, friction = .4, radius = 30 })

– Ball Collision Event Handler
ball.collision = function(self, e)
print("Ball collision " … e.phase … “.”)
if e.phase == ‘ended’ then print(’ ') end
end

– Ball Pre Collision Event Handler
ball.preCollision = function(self, e)
print("**** Ball PreCollision.")
end

ball:addEventListener(‘collision’, ball)
ball:addEventListener(‘preCollision’, ball)
[/code] [import]uid: 136876 topic_id: 7511 reply_id: 126259[/import]

Filed a bug report: http://bugs.anscamobile.com/default.asp?17858 [import]uid: 136876 topic_id: 7511 reply_id: 126363[/import]

We are also observing collision, preCollision, then postCollision in that order on build 894.

The preCollision event is firing 1ms after the collision event according to system.getTimer().

If we set event.contact.isEnabled = false, then postCollision is not fired, but the collision event has already fired and the physical effect of the collision can be observed on the display.

We are unable to find the bug report linked to above, either using that link, or by searching for preCollision. Have you received any updates to this? [import]uid: 120928 topic_id: 7511 reply_id: 127118[/import]

I haven’t had any updates on this. After logging in, I can see the bug report, but I can’t find it in the list. I’m not sure why…

Maybe you should file another one (and hopefully have better luck)? [import]uid: 136876 topic_id: 7511 reply_id: 127130[/import]

We are also observing collision, preCollision, then postCollision in that order on build 894.

The preCollision event is firing 1ms after the collision event according to system.getTimer().

If we set event.contact.isEnabled = false, then postCollision is not fired, but the collision event has already fired and the physical effect of the collision can be observed on the display.

We are unable to find the bug report linked to above, either using that link, or by searching for preCollision. Have you received any updates to this? [import]uid: 120928 topic_id: 7511 reply_id: 127118[/import]

I haven’t had any updates on this. After logging in, I can see the bug report, but I can’t find it in the list. I’m not sure why…

Maybe you should file another one (and hopefully have better luck)? [import]uid: 136876 topic_id: 7511 reply_id: 127130[/import]

I am having the same problem with the collision event firing before the preCollision event so that the physical effect occurs before ‘event.contact.isEnabled = false’ is effective.

I can see the bug report under ‘What’s next’ in the Corona Bug Tracking Tool (towards the bottom of the list). [import]uid: 72695 topic_id: 7511 reply_id: 130877[/import]

I am having the same problem with the collision event firing before the preCollision event so that the physical effect occurs before ‘event.contact.isEnabled = false’ is effective.

I can see the bug report under ‘What’s next’ in the Corona Bug Tracking Tool (towards the bottom of the list). [import]uid: 72695 topic_id: 7511 reply_id: 130877[/import]

The current bug report number is 18185.

It’s been 38 days and no resolution on this bug. It’s a fundamental feature of the physics engine and can’t believe it’s not working for such a long period of time.

This has halted the release of my apps to the iPhone 5…

I would really appreciate some response as to the estimated resolution date please. [import]uid: 72695 topic_id: 7511 reply_id: 132582[/import]

The current bug report number is 18185.

It’s been 38 days and no resolution on this bug. It’s a fundamental feature of the physics engine and can’t believe it’s not working for such a long period of time.

This has halted the release of my apps to the iPhone 5…

I would really appreciate some response as to the estimated resolution date please. [import]uid: 72695 topic_id: 7511 reply_id: 132582[/import]