# Animating camera target also changes position

**URL:** <https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752>\
**Category:** Bugs\
**Created:** [April 26, 2022, 10:06pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752 "2022-04-26T22:06:24Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ajp/32/9504_2.png) [@ajp](https://forum.babylonjs.com/u/ajp)\
**Post date:** [April 26, 2022, 10:06pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/1 "2022-04-26T22:06:24Z")

</div>

I’m not 100% sure this is a bug but it is pretty surprising behaviour: [How to animate changing camera target - #2 by ajp](https://forum.babylonjs.com/t/how-to-animate-changing-camera-target/29751/2)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [April 27, 2022, 12:05pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/2 "2022-04-27T12:05:23Z")

</div>

That’s because you’re using an ArcRotateCamera 🙂 when the target of an ArcRotateCamera changes, it will also update its position so that its distance radius to the target stays the same. For finer control over the camera’s target and position, you’ll want to use the Free/UniversalCamera [Animate changing camera target | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#IA5B1R#2)

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ajp/32/9504_2.png) [@ajp](https://forum.babylonjs.com/u/ajp)\
**Post date:** [April 27, 2022, 5:41pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/3 "2022-04-27T17:41:45Z")

</div>

Great thanks. I think the confusing thing for me was that changing the target with `camera.target = new_target` did not result in the position changing. But when animating its target the position did change. Is that the intended behaviour?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [April 27, 2022, 10:05pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/4 "2022-04-27T22:05:32Z")

</div>

I checked with @PolygonalSun and yeah, that’s intented behavior. What happens is, if you update the target vector without changing its reference (which is what the animation does under the hood), it will keep its existing radius, alpha and beta parameters, which results in the position having to change to accommodate that. But if you use camera.target = … or camera.setTarget(…), then it will recalculate the radius, alpha and beta so that the position doesn’t change. setTarget has a parameter to stop this recalculation, so that it behaves like the animation, but that parameter is false by default. I updated the playground with these different forms of updating the camera target: [Animate changing camera target | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#IA5B1R#5)

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ajp/32/9504_2.png) [@ajp](https://forum.babylonjs.com/u/ajp)\
**Post date:** [April 28, 2022, 8:37am UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/5 "2022-04-28T08:37:52Z")

</div>

Good to know. Thanks. Yes I can get it to update the position using camera.setTarget(pos, true, true, true)

---

<div class="post-metadata">

**Author:** ![fchoisy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/fchoisy/32/28117_2.png) [@fchoisy](https://forum.babylonjs.com/u/fchoisy)\
**Post date:** [August 17, 2022, 12:13pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/6 "2022-08-17T12:13:17Z")

</div>

I believe this should be written in the breaking changes of version 5.

If you take this playground : [https://playground.babylonjs.com/#IA5B1R#6](https://playground.babylonjs.com/#IA5B1R#6) (same as version 1 but without the position animation), and you change the Babylon.js version to 4.2.1, the behavior is not the same as on version 5.19.0.

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ajp/32/9504_2.png) [@ajp](https://forum.babylonjs.com/u/ajp)\
**Post date:** [August 17, 2022, 3:52pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/7 "2022-08-17T15:52:26Z")

</div>

@carolhmj ☝ [fchoisy](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/6) makes a good point, this looks like a breaking change.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [August 17, 2022, 4:01pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/8 "2022-08-17T16:01:53Z")

</div>

Yep yep I was discussing with the team, @RaananW can we add this manually to the breaking change list somehow?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [August 17, 2022, 4:24pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/9 "2022-08-17T16:24:35Z")

</div>

sure, it requires a small edit. assign it to me, i’ll do it and document how to do it for future reference

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [August 17, 2022, 4:55pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/10 "2022-08-17T16:55:37Z")

</div>



---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [August 23, 2022, 4:01pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/11 "2022-08-23T16:01:28Z")

</div>

> <https://github.com/BabylonJS/Babylon.js/pull/12894>

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [August 23, 2022, 4:01pm UTC](https://forum.babylonjs.com/t/animating-camera-target-also-changes-position/29752/12 "2022-08-23T16:01:34Z")

</div>


