Search the Community
Showing results for tags 'applygravity'.
-
Hello, When I am using free camera and attached controls, camera is falling only for about 1 second and than stops. I have to press control key to begin falling again. Can increase this duration or give camera instruction to fall (something like moveWithCollisions )? http://www.babylonjs-playground.com/#21AD8N Thanks!
- 2 replies
-
- freecamera
- camera
-
(and 3 more)
Tagged with:
-
Hi, I trying to create a similar game for learn BabylonJS. I want to create a short game with dynamic objects. I can set the gravity to scene and camera but I can't to any meshes. So camera.applyGravity = true; working fine, but box.applyGravity = true; is ignored. My box still as a static mesh, gravity has no effect to the box. Is it possible to implement gravity on meshes? Am I on the bad way? My scene code below: var createScene = function (engine) { //Creation of the scene var scene = new BABYLON.Scene(engine); //Adding of the light on the scene var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(0, 100, 100), scene); //Adding of the Arc Rotate Camera //var camera = new BABYLON.ArcRotateCamera("Camera", 0, 1, 100, new BABYLON.Vector3.Zero(), scene); var camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(0, 10, -20), scene); var box = BABYLON.Mesh.CreateBox("Box", 6.0, scene); box.position = new BABYLON.Vector3(0, 20, 0); var ground = BABYLON.Mesh.CreatePlane("Plane", 50.0, scene); ground.rotation.x = Math.PI/2; ground.position = new BABYLON.Vector3(0, 0, 0); //COLLISIONS BY GRAVITY //--------------------- //Set gravity to the scene (G force like, on Y-axis. Very low here, welcome on moon) scene.gravity = new BABYLON.Vector3(0, -1, 0); // Enable Collisions scene.collisionsEnabled = true; //Then apply collisions and gravity to the active camera camera.checkCollisions = true; camera.applyGravity = true; //Set the ellipsoid around the camera (e.g. your player's size) //camera.ellipsoid = new BABYLON.Vector3(1, 1, 1); box.checkCollisions = true; box.applyGravity = true; //finally, say which mesh will be collisionable ground.checkCollisions = true; return scene;}
- 2 replies
-
- applygravity
- gravity
-
(and 1 more)
Tagged with: