# targetCamera Bug

**URL:** <https://forum.babylonjs.com/t/targetcamera-bug/48257>\
**Category:** Bugs\
**Created:** [February 24, 2024, 2:11am UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257 "2024-02-24T02:11:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AutoBikeMan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/autobikeman/32/33963_2.png) [@AutoBikeMan](https://forum.babylonjs.com/u/AutoBikeMan)\
**Post date:** [February 24, 2024, 2:11am UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257/1 "2024-02-24T02:11:41Z")

</div>

“I used the code `new TargetCamera('TargetCamera', Vector3.Zero(), editor.scene!)` to create a target camera, but when I saved it as a .babylon file and loaded it, it turned into a free camera.”

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [February 27, 2024, 10:17pm UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257/2 "2024-02-27T22:17:58Z")

</div>

Could you share a repro in the playground ? that would help understanding the issue.

---

<div class="post-metadata">

**Author:** ![AutoBikeMan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/autobikeman/32/33963_2.png) [@AutoBikeMan](https://forum.babylonjs.com/u/AutoBikeMan)\
**Post date:** [February 29, 2024, 1:22am UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257/3 "2024-02-29T01:22:46Z")

</div>

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

then I use “SceneLoader.AppendAsync” to load .babylon file,I found that the ‘targetCamera’ I saved has turned into a ‘freeCamera’ (using getClassName), and it can be moved using the arrow keys, with the view also not fixed, shifting with mouse movements

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [March 1, 2024, 1:08am UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257/4 "2024-03-01T01:08:16Z")

</div>



---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [March 1, 2024, 8:08pm UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257/5 "2024-03-01T20:08:12Z")

</div>

If I’m understanding the code correctly here, the reason why this is happening is because there is no explicit function set up for the `TargetCamera` when being imported (via a .babylon file). This means that the Camera will be imported as a `UniversalCamera` by default. The fix here would be to add a Node constructor function to address this.

Fix is in PR: [TargetCamera: Add Node Constructor code for TargetCamera by PolygonalSun · Pull Request #14827 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/14827)

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [March 4, 2024, 5:26pm UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257/6 "2024-03-04T17:26:28Z")

</div>

Fix is merged

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [March 4, 2024, 5:26pm UTC](https://forum.babylonjs.com/t/targetcamera-bug/48257/7 "2024-03-04T17:26:30Z")

</div>


