2

I've been making a game in Babylon.js. In my game, there is a place where I have put a height map, it shows up when I run the scene, but when I try walking on it (or just standing on it) I fall through. I have searched almost everywhere and I haven't been able to find out why. This is my code:

var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "Assets/Heightmap.png", 1000, 1000, 100, 0, 100, scene, false);
var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
groundMaterial.diffuseTexture = new BABYLON.Texture("Assets/Sand.png", scene);
groundMaterial.diffuseTexture.uScale = 50.0;
groundMaterial.diffuseTexture.vScale = 50.0;
ground.position.y = -2.0;
ground.material = groundMaterial;

Then I run this:

var gravityVector = new BABYLON.Vector3(0,-9.81, 0);
var physicsPlugin = new BABYLON.CannonJSPlugin();
scene.enablePhysics(gravityVector, physicsPlugin);

After all of that, I try to run a BABYLON.PhysicsImposter for the ground but it doesn't work. So far I have tried the BoxImposter, MeshImposter, and HeightMapImposter. None of them worked for me.

I am eager to get an answer, thanks in advance.

12YOK
  • 72
  • 1
  • 9
  • 1
    I have this problem too, and also can't find an answer anywhere. The checkCollisions property of the ground is false and is read only. If I use CreateGround instead, then I can set the checkCollisions property to true and everything works as expected. – bikeman868 Oct 08 '20 at 01:03

1 Answers1

0

if you are trying to do camera collisions you have to use collision engine and not physics: http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity

David Catuhe
  • 1,747
  • 1
  • 10
  • 9
  • 1
    Thanks, but sadly that still doesn't answer my question very much. My character falls through the ground and so does my camera. – 12YOK Jan 16 '18 at 17:39