I am making a game and I am having problems where, when the character jumps on an object, a series of events happen. But, because it collides with the object multiple times, the events happen multiple times, which is what I do not want. What I want is for the event to happen once after the character jumps on the object and stays on top of the object. THEN, let the event happen again ONCE when the character jumps on another object.... etc.
Here is part of my code that is relevant:
function playerCollision( self, event )
--if hit bottom column, u get points
if event.target.type == "player" and event.other.type == "startColumn2" then
if event.phase == "began" then
print ("collided")
addColumns()
timer.performWithDelay(5000, addBody)
startColumn2: translate(-4, 0)
startcolumn2hit = true
end
end
if event.target.type == "player" and event.other.type == "bottomColumn" then
print ("hit column")
onPlatform = true
end
end
How would I make it so I can prevent multiple collisions?