Hello,
I have been trying to understand how the overlapping with Matter.js works for few days and I think it’s a proper time to ask for help.
I would like to create a checkpoint. It should be detected when player pass through this checkpoint.
This is what I have at this moment:
create(){
...
this.player = this.matter.add.sprite(0, 0, "player");
this.checkpoint = this.matter.add.image(1000, 800, 'checkpoint').setIgnoreGravity(true);
this.matter.overlap(this.checkpoint, this.player, this.overlapInfo);
...
}
overlapInfo(){
console.log("Overlap");
}
I found in the documentation that:
Note that bodies can only overlap if they are in non-colliding collision groups or categories.
… so it tried with:
this.player.setCollisionGroup(-1);
this.checkpoint.setCollisionGroup(-1);
but it does nothing and I don’t see any info about what is wrong. I am looking forward for your help!
------ EDIT (SOLVED IN ANOTHER WAY) -------
I have just set the checkpoint as a sensor and checked the collision in a standard way with w “collisionstart”. It works as it should, but I would like to get to know how to make it with overlap.