Understanding Collision events

I’m just getting started out with Corona so bare with me. I have a ball and well game I am using to learn the system. Have created the ball and the well (a sensor) and get the collision event, but I want to check to see if the ball fits in the well.
I have set
well.radius = sensorRadius
ball.radius = ballRadius

physics.addBody(ball,{density=1-dens, friction=0.2, bounce=boun, radius=imp})
physics.addBody( well,“static”, { radius=sensorRadius, isSensor = true} )

and setup a local collision

well.collision = inWell
well:addEventListener( “collision”, well )

but when this code executes:

local function inWell(event )

local obj1 = event.other
local obj2 = event.target

if (obj1.radius < obj2.radius) then

I get obj1 is a nil value. Should event.other not return the ball?
[import]uid: 11767 topic_id: 4157 reply_id: 304157[/import]

A local collision event will pass two objects, the first object will be the object that you set the collision event up for (well) and the second will be the object that has collided with it (ball). So in your code you need to change your function definition to:

local function inWell(self,event)

Currently, even though you’ve named the first parameter in function inWell as ‘event’, it will in fact receive the first object as its value because it is the first parameter. So ‘event’ will actually be ‘well’ and well.other doesn’t exist so will be a nil value. [import]uid: 9064 topic_id: 4157 reply_id: 12931[/import]