I have made a camera switch with two cameras one is ArcRotateCamera and FreeCamera. I wanted to switch camera from Arc to Free with the same position but it just faced to another side or something and also if i scroll in the FreeCamera then switch to ArcRotateCamera camera position just changed to zoomed in. Is there any solution for that? https://playground.babylonjs.com/#S0KJUA#15
Well, first of all, can’t you just rotate the universal camera on creation using camera.rotation.y ?
Second, you are switching cameras, but both camera are listening for canvas inputs all the time. So basically, if you are using universal camera, and then you scroll, doesn’t matter that active camera is universal one, the arcRotate camera is still listening for those canvas inputs.
So bascially when switching the camera you need to detach these controls from the camera which is not used.
https://playground.babylonjs.com/#S0KJUA#16 (changed lines, 34, 38, 40, 44, 239);
Thank you for this solution, but one more thing i think is not working that is if i’m viewing from arc camera from a angle then switch to Universal camera it is positioned to random position and not faced as it was in arc camera. Could you please help me on that?
Corresponding to your case, I would set target of arc camera as target of universal:
In case of switching from arc to universal:
Note: There might be special edge case on arcCamera.beta === 0, so that arc camera flips, because it only has an upVector and no forwardVector.