SpawnTables and Sensors, turning sensor off

Hi, I’ve started building my spawns table.  I can’t figure out how to change the isSensor to false once the objects collide so that I do not get the second “hit” when the objects finally part.

Also is there a better way to do this.  I’m not going to be using physics in my game I just want the sensor feature.  Thanks in advance.

physics = require( “physics” )

physics.start()

physics.setGravity(0,0)

function setup()

watch = 4

hitBox=display.newRect(100,200,60,160)

physics.addBody( hitBox, {isSensor = true} )

hitBox:addEventListener(“collision”,hit)

timer.performWithDelay(10,mix,1)

end

function hit(obj)

if obj.sense == true then             --this is part of the problem

print(“hit”)

obj:setFillColor(255,75,75)

obj.sense = false                     --this is part of the problem

end

end

setup()

function spawnWall(attributes)

–obj = display.newImage(attributes.image)

obj = (attributes.rect)

obj.objTable = attributes.objTable

obj.index = #obj.objTable + 1

obj.objTable[obj.index] = obj

obj.group = attributes.group or nil

obj.group:insert(obj)

obj.type = unbreakable

physics.addBody( obj, {isSensor = true} )

obj.sense = true                     --this is part of the problem

obj:setFillColor(255,255,75)

transition.to(obj, {y=470,time=3000,onComplete=killObj})

return obj

end

localGroup = display.newGroup()

spawnTable = {}

function spawnWall_1()

    for i = 1,1 do

    --spawns = spawnWall({image = “image1.png”, --add image once designed

    spawns = spawnWall({rect = display.newRect(0,-50,200,20),

    objTable = spawnTable,

    group = localGroup,

    })

    end

end

spawnWall_1()

I believe you want obj.isSensor= false

Sorry if I poorly phrased my initial question.

If I change obj.isSensor = false it will now interact with other physics objects correct?.. I want it to be purely a sensor.  

So to rephrase what I want.

Objects collide…print(“hit”)…make the objects unable to interact again. 

Right now what I get is “hit” when they first collide… and a “hit” when they finish colliding.

Well the way to do it is with:

http://docs.coronalabs.com/api/type/Body/isBodyActive.html

But you have to wait until the collision is resolved, which may not be helpful.  Let’s see if Brent has any ideas or anyone else in the community.  Physics are not my strong suit.

I believe you want obj.isSensor= false

Sorry if I poorly phrased my initial question.

If I change obj.isSensor = false it will now interact with other physics objects correct?.. I want it to be purely a sensor.  

So to rephrase what I want.

Objects collide…print(“hit”)…make the objects unable to interact again. 

Right now what I get is “hit” when they first collide… and a “hit” when they finish colliding.

Well the way to do it is with:

http://docs.coronalabs.com/api/type/Body/isBodyActive.html

But you have to wait until the collision is resolved, which may not be helpful.  Let’s see if Brent has any ideas or anyone else in the community.  Physics are not my strong suit.