Mesh physics imposter doesnt work

I’m making minecraft with babylon.js. I made object, then set mesh physics imposter.I also set player’s physics imposter as sphere imposter. However, they dont collide and player just goes through map.

map is made manually, like the code below.

    Cube(b);//add vertices then create face etc.

I set to update physics imposter every time map model is updated(when block is placed or removed)

mesh.physicsImpostor = new BABYLON.PhysicsImpostor(mesh, BABYLON.PhysicsImpostor.MeshImpostor, {restitution:0}, scene);

How can I make these collide? Please help me. thanks.

Pinging @trevordev

To get faster help you may want to share a repro in the playground :slight_smile:

Sorry but it’s private project. I cannot open-source it.

No need to do whole project. Using a simplified map and player recreate the problem. In other words can you show that in a playground that mesh physics imposter is not working in a simplified situation?

1 Like

Hi @Immortality,

First SWEET!!! So cool that you’re making Minecraft with Babylon! Can’t wait to see your progress on that.

I’m not sure if this helps, but I put together a playground with a cube and sphere to show off the basics of how physics works.

This should show the absolute basics of how to use physics imposters with your scenario of having a cube and sphere.

I’m sorry but it is very hard to compress all important features of my project.
One thing I need to tell you is that PlaneImposter works.(but not what I wanted.).

@Immortality Can you share what babylon methods you are using to create the map. If you can have a playground that constructs a triangle the same way, that would be helpful.

maybe this is the most simple, direct function what I am doing. other functions have too many strange feature.

function UpdateMesh(){
var normals = [];
BABYLON.VertexData.ComputeNormals(newVertices,newTriangles, normals);
var vertexData = new BABYLON.VertexData();
vertexData.positions = newVertices;
vertexData.indices = newTriangles;
vertexData.normals = normals;
vertexData.uvs = newUV;
mesh.physicsImpostor = new BABYLON.PhysicsImpostor(mesh, BABYLON.PhysicsImpostor.PlaneImpostor, {restitution:0}, scene);

It looks to work here: Babylon.js Playground is your scenario different?