Kilombo Posted April 21, 2015 Share Posted April 21, 2015 Good afternoon everyone, For some reason, my planets function is giving me the error in the topic. Everything works right in the units class, but in planets is not working. And i can't seem to find the answer. Help wanted plz The console is returning "Uncaught TypeError: Cannot read property 'setPhysicsState' of undefined" in system.js line 104, is the one in bold. I'm trying to implement Oimo.js in my project btw. system.prototype.setPlanets = function (){ var temp = this; BABYLON.SceneLoader.ImportMesh(name, "Assets/babylonreadyfiles/", "planets.babylon", scenes[0], function(newMeshes) { newMeshes[0].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet1 = newMeshes[0]; var planet2 = newMeshes[1]; newMeshes[1].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet3 = newMeshes[2]; newMeshes[2].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet4 = newMeshes[3]; newMeshes[3].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet5 = newMeshes[4]; newMeshes[4].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet6 = newMeshes[5]; newMeshes[5].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet7 = newMeshes[6]; newMeshes[6].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet8 = newMeshes[7]; newMeshes[7].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); var planet9 = newMeshes[8]; newMeshes[8].setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 1000, restitution:0.001 }); if (temp.planet1 === "planet1"){ planet1.scaling.x = 500; planet1.scaling.y = 500; planet1.scaling.z = 500; planet1.position.x = temp.posx/2; planet1.position.y = 5; planet1.position.z = temp.posz/2; planet1.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[0].checkCollisions = true; scenes[0].beginAnimation(planet1, 0, 100, true, 0.04); console.log(planet1); //planet1.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet1,temp.planetId1,"planet"); } if (temp.planet2 === "planet2"){ planet2.scaling.x = 300; planet2.scaling.y = 300; planet2.scaling.z = 300; planet2.position.x = temp.posx*(6/4); planet2.position.y = 5; planet2.position.z = temp.posz; planet2.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[1].checkCollisions = true; scenes[0].beginAnimation(planet2, 0, 100, true, 0.04); //planet2.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet2,temp.planetId2,"planet"); } if (temp.planet3 === "planet3"){ planet3.scaling.x = 750; planet3.scaling.y = 750; planet3.scaling.z = 750; planet3.position.x = temp.posx*(6/4); planet3.position.y = 5; planet3.position.z = temp.posz*(8/4); planet3.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[2].checkCollisions = true; scenes[0].beginAnimation(planet3, 0, 100, true, 0.04); // planet3.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet3,temp.planetId3,"planet"); } if (temp.planet1 === "planet4"){ planet4.scaling.x = 500; planet4.scaling.y = 500; planet4.scaling.z = 500; planet4.position.x = temp.posx/2; planet4.position.y = 5; planet4.position.z = temp.posz/2; planet4.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[3].checkCollisions = true; scenes[0].beginAnimation(planet4, 0, 100, true, 0.04); //planet4.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet4,temp.planetId1,"planet"); } if (temp.planet2 === "planet5"){ planet5.scaling.x = 300; planet5.scaling.y = 300; planet5.scaling.z = 300; planet5.position.x = temp.posx; planet5.position.y = 5; planet5.position.z = temp.posz*(7/4); planet5.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[4].checkCollisions = true; scenes[0].beginAnimation(planet5, 0, 100, true, 0.04); //planet5.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet5,temp.planetId2,"planet"); } if (temp.planet3 === "planet6"){ planet6.scaling.x = 750; planet6.scaling.y = 750; planet6.scaling.z = 750; planet6.position.x = temp.posx*(7/4); planet6.position.y = 5; planet6.position.z = temp.posz/2; planet6.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[5].checkCollisions = true; scenes[0].beginAnimation(planet6, 0, 100, true, 0.04); // planet6.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet6,temp.planetId3,"planet"); } if (temp.planet1 === "planet7"){ planet7.scaling.x = 500; planet7.scaling.y = 500; planet7.scaling.z = 500; planet7.position.x = temp.posx/2; planet7.position.y = 5; planet7.position.z = temp.posz/2; planet7.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[6].checkCollisions = true; scenes[0].beginAnimation(planet7, 0, 100, true, 0.04); //planet7.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet7,temp.planetId1,"planet"); } if (temp.planet2 === "planet8"){ planet8.scaling.x = 300; planet8.scaling.y = 300; planet8.scaling.z = 300; planet8.position.x = temp.posx; planet8.position.y = 5; planet8.position.z = temp.posz*(7/4); planet8.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[7].checkCollisions = true; scenes[0].beginAnimation(planet8, 0, 100, true, 0.04); //planet8.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet8,temp.planetId2,"planet"); } if (temp.planet3 === "planet9"){ planet9.scaling.x = 750; planet9.scaling.y = 750; planet9.scaling.z = 750; planet9.position.x = temp.posx*(7/4); planet9.position.y = 5; planet9.position.z = temp.posz/2; planet9.actionManager = new BABYLON.ActionManager(scenes[0]); newMeshes[8].checkCollisions = true; scenes[0].beginAnimation(planet9, 0, 100, true, 0.04); // planet9.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 0 }); makeOverOut(planet9,temp.planetId3,"planet"); } });}; Quote Link to comment Share on other sites More sharing options...
Kilombo Posted April 21, 2015 Author Share Posted April 21, 2015 Well..i sorted out.. now the planets just fall of.... but they shouldn't cause i've set gravity to zero. Anyone knows why? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 21, 2015 Share Posted April 21, 2015 Did you set the physics gravity to 0?scene.enablePhysics(new BABYLON.Vector3(0, 0, 0), new BABYLON.OimoJSPlugin()); Quote Link to comment Share on other sites More sharing options...
Kilombo Posted April 21, 2015 Author Share Posted April 21, 2015 Yap.. I do. Strange thing, If I put no mass on the planets they still stand, but if I put some mass, they just disappear. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.