Hello! recently I made a house for testing .babylon files. The problem is is that when I use
BABYLON.SceneLoader.ImportMesh("", "assets/", "Clara_th.babylon", scene, function (newMeshes) {
let house = newMeshes[0];
house.checkCollisions = true;
house.position = new BABYLON.Vector3(75, 14, 50);
});
I get collision with my walls, but only 1 of them move. I used boxes to make the walls and floor, all seperate objects, but the don’t move as one. Is there any way to fix this? I tried this:
BABYLON.SceneLoader.ImportMesh("", "assets/", "Clara_th.babylon", scene, function (newMeshes) {
let house = newMeshes[0,1,2,3,4,5];
house.checkCollisions = true;
house.position = new BABYLON.Vector3(75, 14, 50);
});
BABYLON.SceneLoader.ImportMesh("", "assets/", "Clara_th.babylon", scene, function (newMeshes) {
for (var index = 0; index < newMeshes.length; index++) {
let house = newMeshes[index];
house.checkCollisions = true;
house.position = new BABYLON.Vector3(75, 14, 50);
}
});
I hope you follow @Deltakosh’s response, as you need to know how to correctly assign an array or element(s) of an array correctly. You’ll be manipulating arrays constantly if you continue to code.
The immediate problem will be that all meshes will be moved to the same position
i suggest parenting to a transformNode or empty mesh, then move that parent.
BABYLON.SceneLoader.ImportMesh("", "assets/", "Clara_th.babylon", scene, function (newMeshes) {
let parent = new BABYLON.TransformNode();
parent .position = new BABYLON.Vector3(75, 14, 50);
for (var index = 0; index < newMeshes.length; index++) {
let house = newMeshes[index];
house.checkCollisions = true;
house.parent = parent;
}
});