I'm working with cannon-es (a maintained fork of cannon.js). I need to fix an object in space for a certain period of time. So, I do body.sleep() in these cases.
The problem is that object can collision with other object and it wakes up. So I add body.collisionResponse = 0 but it doesn't work. body becomes a ghost object (no response to collision) but still wake up on collision.
Is there a way to avoid wake up on collision?
I found the collisionfiltergroup and collisionFilterMask properties.
So, in the body creation:
const body = new CANNON.Body({
mass: 1,
shape: shape,
material: this.physicsWorld.defaultMaterial,
collisionFilterGroup: 1,
collisionFilterMask: 1
})
And, when it has to get fixed:
body.sleep()
body.collisionFilterMask = 2