# Camera inertia vibrates on collision

**URL:** <https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269>\
**Category:** Bugs\
**Created:** [March 9, 2022, 3:19pm UTC](https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269 "2022-03-09T15:19:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jannick](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jannick/32/36560_2.png) [@Jannick](https://forum.babylonjs.com/u/Jannick)\
**Post date:** [March 9, 2022, 3:19pm UTC](https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269/1 "2022-03-09T15:19:12Z")

</div>

Hello! Currently I’m trying to implement a scene without any form of gravity, just setting the player.y position each frame (as the player height).  
Wanting to have basic collisions as well I enabled that. But when I’m colliding with something, at first it seems it functions fine, camera gets blocked by the box. But if you look closely, you can see (what I assume is the camera inertia) being applied after releasing any held movement key and thereby giving this vibrating visual effect shortly after.

PG:

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

---

<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 9, 2022, 4:16pm UTC](https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269/2 "2022-03-09T16:16:16Z")

</div>

cc @Cedric our king of everything physics 🙂

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 9, 2022, 4:23pm UTC](https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269/3 "2022-03-09T16:23:30Z")

</div>

I don’t see the vibrating effect. I guess I’m not looking at the right thing.  
Anyway, you can improve the collision/response quality with `collisionRetryCount` like in this PG:  
[planet | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#4HUQQ#1851)

---

<div class="post-metadata">

**Author:** ![Jannick](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jannick/32/36560_2.png) [@Jannick](https://forum.babylonjs.com/u/Jannick)\
**Post date:** [March 9, 2022, 8:49pm UTC](https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269/4 "2022-03-09T20:49:58Z")

</div>

It might be a bit easier to notice if you clip through the box a bit with the frustum near plane.  
After you’ve collided, release the key and you should be able to spot ever so slightly the vibration right after.

Here’s the new PG:

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 10, 2022, 10:26am UTC](https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269/5 "2022-03-10T10:26:24Z")

</div>

I think I see the vibration. This is caused by the algorithm that tries to slide along the surface (more back because of collision, slide a little, move forward and so on). It’s also caused by the camera inertia.  
At his point, the only solution I see is to recode a (big) portion of the collision/response system. Which might not happen soon because of next release and code freeze.  
To mitigate the issue, you can set `camera.inertia` to a lower value or even 0.  
Or maybe with a bit more work, use a physics impostor with the camera attached to a sphere.

---

<div class="post-metadata">

**Author:** ![Jannick](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jannick/32/36560_2.png) [@Jannick](https://forum.babylonjs.com/u/Jannick)\
**Post date:** [March 10, 2022, 11:39am UTC](https://forum.babylonjs.com/t/camera-inertia-vibrates-on-collision/28269/6 "2022-03-10T11:39:19Z")

</div>

I see, thanks for looking into it and giving some feedback 😃  
I’ve tested a bunch myself and it seems that enabling gravity, ground collisions and setting proper collider dimensions on the camera, also revents the vibration from happening.

If I find some other solutions I will most likely post some update progress here for some workarounds.

Wish you a great day!
