Panuchka Posted September 14, 2016 Share Posted September 14, 2016 Hi, just a short question about physics usage. I use Cannon.js for now, moving to Oimo.js later on. Anyways, I'm making a Bomberman clone with physics turned on. Let's say that I have a 20 x 20 grid. Bomb explodes in my game and this should destroy some random tile. After I dispose the mesh, the physics impostor seems to be there still, since my trusty old debug ball happily rolls over the empty space. The question is: How to remove mesh and its physics properties from the scene? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 14, 2016 Share Posted September 14, 2016 Hey Based on the following code, I woudl say that physics is disabled: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1137 Can you reproduce your issue on the playground? Quote Link to comment Share on other sites More sharing options...
Panuchka Posted September 15, 2016 Author Share Posted September 15, 2016 Here you go sir! http://www.babylonjs-playground.com/#BHMRT Although I've been thinking of maybe dumping the use of physics engine and just use the collisions. What would I miss? If the only thing I need is some falling from the platforms, it is probably wiser to use something simpler? I'm curious, have you investigated how much the physics engine slows down everything? Quote Link to comment Share on other sites More sharing options...
Panuchka Posted September 15, 2016 Author Share Posted September 15, 2016 I managed to fix it. The problem was that I did not assign the physics impostor to the mesh properly: // RIGHT tileMeshCopy.physicsImpostor = new BABYLON.PhysicsImpostor(tileMeshCopy, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, restitution: 0.9 }, scene); // WRONG new BABYLON.PhysicsImpostor(tileMeshCopy, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0, restitution: 0.9 }, scene); Here is the working one:http://www.babylonjs-playground.com/#BHMRT#1 I kind of thought that just creating the physics impostor would attach it to the mesh itself. Oh well RaananW and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 15, 2016 Share Posted September 15, 2016 Perfect Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.