Collision of Bullet

I have created a bullet shooting game. And I want to add some animation when bullet collide on the box .
I have tried collision detection methods… But not able to detect the collision

Hello and welcome to the Babylon community! Have you added a physics impostor to the box?

You are trying to add PhysicsImposter to root of .gltf-file. This won’t work, you have to add collision_shape in i.e. Blender (like: How to use MeshImpostor with blender imported glb? - #5 by paulbonneau), and might have to switch to .babylon-file (simply use sandbox to export from gltf). And then you can iterate through actual meshes like this:

for(const mesh of res.meshes) {
     if(!mesh.name.includes('__root__')) mesh.physicsImpostor = new BABYLON.PhysicsImpostor(mesh, BABYLON.PhysicsImpostor.CustomImpostor, { mass: 0, restitution: 100}, scene);
 }

Alternatively you can create a collision-Mesh in Blender, then you don’t have add Imposter to every mesh.

Additionally CustomImposter might require AmmoJSPlugin.

3 Likes