Recently started to learn Babylonjs, and by following some tutorials I was able to import a heightmap terrain and a glb character (player). Player is a child of capsule parent.
const outer = new PhysicsShapeCapsule(
new Vector3(0, 2, 0),
new Vector3(0, 0.35, 0),
0.40,
scene
);
//yTilts.rotation = outer.rotation;
yTilts.position = position;
var model = await SceneLoader.ImportMeshAsync("", directoryPath, fileName, scene, () => {});
const body = model.meshes[0];
body.position = position;
body.isPickable = false; //so our raycasts dont hit ourself
body.getChildMeshes().forEach(m => {
m.isPickable = false;
});
const aggregate = new PhysicsAggregate(body, outer, { mass: 75, friction: 1, restitution: 0 }, scene);
aggregate.body.disablePreStep = false;
return {
mesh: body as Mesh,
animationGroups: model.animationGroups,
yTilt: yTilts,
}
Problem is, this capsule doesn’t stand on ground. it just falls off & keep sliding on ground. Please guide me to the right direction to find what am I doing wrong here.