• Content Count

  • Joined

  • Last visited

  1. The code is too long to recreate it. The problem with dispose is that the object is in fact deleted from the scene but intersectsMesh() still perceives it as if it is still there.
  2. Hello, I have a problem with disposing objects. I generate multiple objects in my game and cannot seem to dispose them. Is there any way to destroy the objects? I also tried the dispose() method but it didn't quite work. Thank you!
  3. I did this but now the model doesn't show on screen..
  4. It's hard to use playground since I have some imported meshes in my code + there is so many more things happening that it's a big pile of stuff right now xD otherwise I don't have any real experience with the physics engine so I would really love it if I can avoid using it thanks for everything I'll try to figure out a way to implement the example in my code
  5. I don't understand how you change the position of the box here? I would like something like this, yes, it's hard to show it cause its a whole game
  6. Okay, I did it and now it loads, but it still doesn't move like the parent does.. what do I do now? I also tried to use the translate function but it also doesn't work, I get a type error: monster.translate is not a function monster.translate(BABYLON.Axis.Z, -0.05, BABYLON.Space.WORLD);
  7. 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.isVisible = true; newMeshes1.checkCollisions = true; newMeshes1.scaling = new BABYLON.Vector3(1, 0.3, 1); newMeshes1.position = new BABYLON.Vector3(30, -8, 2); newMeshes1.material = posast; } }); monster.parent = parentMonster; parentMonster.position = new BABYLON.Vector3(30, -8, 2); parentMonster.isVisible = false; Please help, I'm desperate.Thank you.
  8. Hi! I'm new to this so this is probably a dumb question.. Been trying to make a game where object moves through labyrinth without going through walls. I implemented collision detection to the point where I'm sure its working but when I tried to move it with .position method there was no collision happening so I ended up using the moveWithCollisions method. This works but once you press the button the object starts moving and doesn't ever stop it just changes direction at another key press. It also increases speed and both of this thing make it very useful to move it through gaps in the walls and navigate it.. So is there a way to control speed and stop mesh before there is a collision/intersection? Or is there a whole different better way to implement movement of that kind? Any advice, opinion and info welcome and thanks so much This is how code for one key press looks like: (sphere is the object we're trying to move - i have yet to import it but at least I know how to do that) window.addEventListener("keydown", function(evt) { if (evt.keyCode==87){//forward scene.registerBeforeRender(function () { sphere.computeWorldMatrix(true); //labyrinth.computeWorldMatrix(true); if (!sphere.intersectsMesh(labyrinth, true)) { //sphere.applyImpulse(new BABYLON.Vector3(premikanjeX, 0, premikanjeZ), sphere.position); var forward = new BABYLON.Vector3(parseFloat(Math.sin(parseFloat(sphere.rotation.y))) / 8, 0, parseFloat(Math.cos(parseFloat(sphere.rotation.y))) / 8); sphere.moveWithCollisions(forward); } });}}, false);