Can someone please point me in the right direction so that while two objects are detecting a collision their health would keep being reduced. Right now I can only to seem to figure out how to reduce the health once until the collide again. The objects register the collision fine but I need help on figuring out how to flag the objects so that until the objects are no longer colliding the health stops going down.
[code]
local function onCollision( event )
if ( event.phase == “began” ) then
if (event.object1.myName == “Ball”) then
timer.performWithDelay(1000, removeBall(event.object1.myName), 1)
elseif (event.object1.myName == “Gramps” and event.object2.myName == “Ai”) then
PlayerHit = true;
gramps.health = gramps.health - 1;
end
print( "began: " … event.object1.myName … " & " … event.object2.myName )
elseif ( event.phase == “ended” ) then
print( "ended: " … event.object1.myName … " & " … event.object2.myName )
if (PlayerHit) then
end
end
end
[import]uid: 16265 topic_id: 7695 reply_id: 307695[/import]