# Same camera on switch

**URL:** <https://forum.babylonjs.com/t/same-camera-on-switch/34373>\
**Category:** Questions\
**Tags:** camera\
**Created:** [September 30, 2022, 1:05pm UTC](https://forum.babylonjs.com/t/same-camera-on-switch/34373 "2022-09-30T13:05:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![imarabinda](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/imarabinda/32/27201_2.png) [@imarabinda](https://forum.babylonjs.com/u/imarabinda)\
**Post date:** [September 30, 2022, 1:05pm UTC](https://forum.babylonjs.com/t/same-camera-on-switch/34373/1 "2022-09-30T13:05:03Z")

</div>

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](https://playground.babylonjs.com/#S0KJUA#15)

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [September 30, 2022, 1:37pm UTC](https://forum.babylonjs.com/t/same-camera-on-switch/34373/2 "2022-09-30T13:37:22Z")

</div>

Hey.

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](https://playground.babylonjs.com/#S0KJUA#16) (changed lines, 34, 38, 40, 44, 239);

---

<div class="post-metadata">

**Author:** ![imarabinda](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/imarabinda/32/27201_2.png) [@imarabinda](https://forum.babylonjs.com/u/imarabinda)\
**Post date:** [September 30, 2022, 1:49pm UTC](https://forum.babylonjs.com/t/same-camera-on-switch/34373/3 "2022-09-30T13:49:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Takemura](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/takemura/32/25836_2.png) [@Takemura](https://forum.babylonjs.com/u/Takemura)\
**Post date:** [October 1, 2022, 6:35pm UTC](https://forum.babylonjs.com/t/same-camera-on-switch/34373/4 "2022-10-01T18:35:13Z")

</div>

Corresponding to your case, I would set target of arc camera as target of universal:

```auto
universalCamera.setTarget(arcCamera.target)

```

In case of switching from arc to universal:

```auto
arcCamera.setTarget(universalCamera.getFrontPosition(arcCamera.radius))

```

The Playground:

> **[Babylon.js Playground](https://playground.babylonjs.com/#DJP9H4)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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.

---

<div class="post-metadata">

**Author:** ![jvanderdoes](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jvanderdoes/32/31978_2.png) [@jvanderdoes](https://forum.babylonjs.com/u/jvanderdoes)\
**Post date:** [February 2, 2024, 4:13pm UTC](https://forum.babylonjs.com/t/same-camera-on-switch/34373/5 "2024-02-02T16:13:07Z")

</div>

The other edge case I’ve run into is when targetScreenOffset is non-zero. Any thoughts on how to take that into account?
