0
votes

So I'm creating a game where an enemy is firing a bullet. The bullet eventrully hits a collision I made, when it hits the end of the screen. Im wanting at this point to remove it and clear the address back to a nil value. When checking the address before and after the collision, no change was made. please help with any insight you might have on this.

local onCollision = function(event)
        if event.phase == "began" then
            event.object2:removeSelf();
            event.object2 = nil;
        end
end
Runtime:addEventListener("collision",onCollision);
1

1 Answers

1
votes
local onCollision = function(event)
        if event.phase == "began" then
            event.target:removeSelf();
            event.target= nil;
        end
end
Runtime:addEventListener("collision",onCollision);