Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All collisions are triggered instead of just the one that has the event listener #10

Open
KokoDoko opened this issue May 19, 2021 · 0 comments

Comments

@KokoDoko
Copy link

If I create a Matter physics object, and add a collision event listener, the collision event gets fired for EVERY collision in the world, instead of just the one object that I added the listener to.

this.physicsBox = Matter.Bodies.rectangle(x, y, w, h, options)
Matter.Composite.add(world, this.physicsBox)

this.physicsBox.onCollide((pair) => {
     console.log('Box got hit!', pair.bodyA.label, pair.bodyB.label)         // this logs every collision in the world, even if this box is not part of it.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant