Hello, I’d like to turn off the body interaction (i.e. bouncing) for certain objects in the scene, but still receive their collision events (or detect their collisions somehow). Is it possible by simply switching some body property off, or do I need to implement custom collision detection for such a case?
Hi, if I understand, maybe .setBounce(0)
on each body, helps
I had expressed myself imprecisely. setBounce(0)
negates the bouncing, but it stops the object on collision. I need the object to be able to pass through any obstacle, like immaterial.
Does this help?
As for the collision category mentioned there, it doesn’t help, I am afraid. As i said, I need the object body to pass through other objects, while the collision events (like 'collisionstart'
) still fire. So, the collision needs to be detected, but the object needs to go through with unchanged velocity. The ‘collision category’ feature doesn’t seem to separate these two phenomena.
As for the answer from fselcukcan… I don’t understand it, but will try
Set the matter body to be “sensor”. Here is an example showing bodies that are sensors, they trigger callbacks but do not collide. https://labs.phaser.io/view.html?src=src\physics\matterjs\compound%20sensors.js
This is exactly what I needed, thank you!
object.setSensor(true)
does the trick.