Dear everybody,
I have some question.
When I use a collision like as follows
local function CollisionFun(event)
local CollisionObject = event.other
if collideObject.surfaceType == Enemy[i].surfaceType then
if event.contact.isTouching == true then
print(“attack”)
end
end
end
Most of the time this operation is not a problem,but sometimes he will appear Runtime error
.
attempt to index field ‘contact’ (a nil value)
stack traceback:
in function ‘?’
In general, after the object is removed, the Collision Listener of the object will be canceled.
Then to completely avoid this problem, should I manually remove it?
Like under print(“attack”), add this line.
event.target:removeEventListener( “collision”, CollisionFun)
May I ask if I should do this to make sure there is no problem?
Thanks everyone.

