Disable all collision impacts (Matter.js)

How can I stop all impacts from a collision? I’m using Matter.js.

I’ve tried:

object.setVelocity(0, 0)
object.setAngularVelocity(0)

However, the object is still rotating and moving.

I’ve found a workaround, but I don’t like it because of setTimeout():

object.setStatic(true)

setTimeout(() => {
  object.setStatic(false)
})

Alternatively, it would also be nice to do it configuratively, something like { collisionDetectionOnly: true }, so that a collision is detected but nothing else happens. I’ve read about object.isSensor() but it doesn’t seem to have any noticable impact.

Thanks a lot.

Got it, the trick is to use object.setSensor(true) and it will be notified about collisions, but not react to them.

1 Like