Playing with camera, trying to figured out on how to:
Force UniversalCamera to walk in only X direction? so for example If current camera position is at the sky, I want camera to walk on the x direction rather than toward sky
Based on location, I want to restrict maximum camera X rotation/position.
Do I need to add cameraDirection on some event? cause if I simply add camera.cameraDirection.y = 0; and move position with mouse/keyword, it doesn’t works. Babylon.js Playground
Also for second I am thinking another solution, I want to be able to control camera movements with buttons.
After reading a lot I found about Babylon GUI, and was able to create a GUI with 4 buttons, now I wants to learn on how to control the camera movement with those buttons, just like we click arrows on keyboard or mouse pointer movements to move forward/back,left/right etc.
Thank you @Evgeni_Popov, It was almost near on how I was thinking, But it doesn’t animate /go smoothly like when we do with mouse forward. so to overcome this here is my finding:
this animates it smoothly , is that correct way to animate camera?
ps. I noticed camera speed is very slow when processing in engine.runRenderLoop
to overcome the speed issue: I am calling camera position multiple times, like this:
if (isForwardBtnDwn) {
camera.position.addInPlace(camera.getDirection(BABYLON.Vector3.Forward()));
camera.position.addInPlace(camera.getDirection(BABYLON.Vector3.Forward()));
camera.position.addInPlace(camera.getDirection(BABYLON.Vector3.Forward()));
}
sorry got stuck here, how can I also rotate camera without walking / and with walking also will be good to know.
I included two new buttons buttonRotateLeft and buttonRotateRight https://www.babylonjs-playground.com/#IA7LXQ#7
if (isRotateLeftBtnDwn) {
// what value?
}
if (isRotateRightBtnDwn) {
// what value?
}
if (isRotateLeftBtnDwn) {
camera.cameraRotation.addInPlace(camera.getDirection(BABYLON.Vector3.Left()).scale(0.1));
}
if (isRotateRightBtnDwn) {
camera.cameraRotation.addInPlace(camera.getDirection(BABYLON.Vector3.Right()).scale(0.1));
}