Hello, everyone. Can you teach me that mesh collision?
I put meshImpostor when loading the model. However, the model always slips past the other model without responding to the collision. Your help would be very appreciated. Thank you.
My code↓
scene.enablePhysics(new BABYLON.Vector3(0,-10,0), new BABYLON.AmmoJSPlugin());
BABYLON.SceneLoader.ImportMesh("", "", "model.gltf", scene, function (newMeshes, particleSystems, skeletons) {
newMeshes[0].physicsImpostor = new BABYLON.PhysicsImpostor(newMeshes[0], BABYLON.PhysicsImpostor.MeshImpostor, {mass: 0, restitution: 0.8});
}
newMeshes[0] is probably not the right mesh. When loading a gltf/glb file, the first “mesh” is in fact a transform node that handles converting from right handed to left handed system. So, try newMeshes[1] instead. If it still does not work, you should provide a repro in the Playground so that people can help.
Yeah, I’m gonna have to agree with @Evgeni_Popov. Another option that you could also look into is adding a mesh to act as a sort of bounding box or collision mesh. Here’s an example: Babylon.js Playground (babylonjs.com)
When the thing I am moving collides with something else, I want it to stop moving without fusing with the other thing. The meshimpostor is a slow process and the bumped object will move, so I decided to use an intersectsMesh to detect collision and stop the movement. I also understood that newmesh[1] can detect an intersectmesh instead of newmesh[0].
I would like to use other advice in the future, such as meshImpostor.