Quantcast
Viewing all articles
Browse latest Browse all 388

Grouping - parent child relationship

Hello,

 

I have a problem regarding the parent - child relationship. I have imported a 3d object from blender and I would like to bind it to an invisible mesh (box) so it would move. It doesn't work no matter which way I try it. Here's the code:

 

var monster;

var parentMonster = BABYLON.Mesh.CreateBox("p", 3, scene);
 
            BABYLON.SceneLoader.ImportMesh("", "assets/", "monster1.babylon", scene, function (newMeshes1) {
                monster= new BABYLON.StandardMaterial("assets/", scene);
                monster.diffuseTexture = new BABYLON.Texture("assets/monsterlayer1.bmp", scene);
                monster.diffuseTexture.uScale = 1;
                monster.diffuseTexture.vScale = 1;
 
                for(var i = 0; i < newMeshes1.length; i++) {
                    newMeshes1[i].isVisible = true;
                    newMeshes1[i].checkCollisions = true;
                    newMeshes1[i].scaling = new BABYLON.Vector3(1, 0.3, 1);
                    newMeshes1[i].position = new BABYLON.Vector3(30, -8, 2);
                    newMeshes1[i].material = posast;
                } 
            });
            monster.parent = parentMonster;
 
            parentMonster.position = new BABYLON.Vector3(30, -8, 2);
            parentMonster.isVisible = false;
 
Please help, I'm desperate.
Thank you.

Viewing all articles
Browse latest Browse all 388

Trending Articles