【发布时间】:2018-01-15 01:31:46
【问题描述】:
我一直在用 Babylon.js 制作游戏。在我的游戏中,有一个地方放置了高度图,当我运行场景时它会显示出来,但是当我尝试在上面行走(或只是站在上面)时,我会摔倒。我几乎在所有地方都进行了搜索,但无法找出原因。这是我的代码:
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;
然后我运行这个:
var gravityVector = new BABYLON.Vector3(0,-9.81, 0);
var physicsPlugin = new BABYLON.CannonJSPlugin();
scene.enablePhysics(gravityVector, physicsPlugin);
在所有这些之后,我尝试为地面运行 BABYLON.PhysicsImposter,但它不起作用。到目前为止,我已经尝试过 BoxImposter、MeshImposter 和 HeightMapImposter。它们都不适合我。
我很想得到答案,在此先感谢。
【问题讨论】:
-
我也有这个问题,也找不到任何答案。地面的 checkCollisions 属性为 false 并且是只读的。如果我改用 CreateGround,那么我可以将 checkCollisions 属性设置为 true,一切都会按预期工作。
标签: javascript babylonjs cannon.js