Is it possible to enable gravity and collision separately for a mesh

I’m trying to enable collision and gravity on meshes seperatly in my application. This is triggered on a toggle button event. I used physicsImpostor to enable gravity, when using this the collision is enabled by default. when I try to disable the collision by setting “checkCollisions” to false, it not working.
Is it possible to enable and disable collision without affecting the gravity functionality of the mesh.

checkCollisions uses the native collision system of BabylonJS, so in case of physics engine set it to false.

In the physics engine you can set collisionFilterGroup and collisionFilterMask. A collision between A and B will happen if A.collisionFilterGroup & b.collisionFilterMask !== 0.

So for every “digit” of A and B the AND-operator is applied. By default group and mask is -1.

The example PG of @Cedric:

But I recommend to use new Havok physics engine:

How collision filters are set in Havok:


Thanks for the response. I tried the collisionFilterGroup and collisionFilterMask, it works. Just need to try the Havok physics engine.

1 Like

Is it possible to keep the collision enabled and disable just the gravity of a mesh.

Assuming we talk about Havok, then the PhysicsBody can setGravityFactor:

Otherwise this topic explains workarounds in other physic engines: