I'm new to Matter.js, I'm really confused about how to remove a specific body in the pair after a collision, here is my code:
Matter.Events.on(engine, 'collisionEnd', function(event){
var i, pair,
length = event.pairs.length;
for(i = 0; i<length; i++){
pair = event.pairs[i];
if(pair.bodyA === ball){
continue;
}
else{
World.remove(world, pair.bodyA);
}
}
});
I want to delete the squares after having a collision with the ball, but the code isn't working.