I am trying to detect when two object collide with each other, but I am not sure how to do it.
I have the following scene, which adds two physics images to the scene. I just need a way to detect when the two collide.
export class MainGame extends Scene {
public create() {
// Create the player
this.player = this.matter.add.image(300, 100, 'player')
// Create a pillar
let pillar = this.matter.add.image(500, 0, 'pillar1', null, { isStatic: true })
// Somehow detect collision between the two...
}
}
What I cannot figure out is how to detect when the player collides with the pillar. Everything I have searched for is how to do this using arcade physics, but I am using matter physics.
I cannot find any information on how to detect collision and then run a function.