Quantcast
Channel: Babylon.js
Viewing all articles
Browse latest Browse all 388

Limiting free camera movement up or down

$
0
0

Hi

I have applied a freecamera to my project.

camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(-40, cameraHeight,-132), scene);

I have applied gravity to it so that it won't fly

ie: camera.applyGravity = true;

I have given it a constant height (cameraHeight)

 

scene.registerBeforeRender(function () {
                    scene.activeCamera.position.y = cameraHeight;

});

 

Now the problem is that when I move the mouse up and down along the Y axis the camera rotates (in essence on the x-axis). So the camera is elevated and it's like flying.I have checked the ESPILIT demo and it's the same problem (Espilit.babylon has camera gravity enabled).

 

So is there a command which limits the rotation of the free camera up and down (or left and right) ?

If I need to calculate the rotation in registerBeforeRender then my 2nd question, can I stop a camera?


Viewing all articles
Browse latest Browse all 388

Trending Articles