# Camera shake exceptions

**URL:** <https://phaser.discourse.group/t/camera-shake-exceptions/15459>\
**Category:** Phaser 3\
**Created:** [August 16, 2025, 12:14am UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459 "2025-08-16T00:14:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bread](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bread/32/9050_2.png) [@bread](https://phaser.discourse.group/u/bread)\
**Post date:** [August 16, 2025, 12:14am UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/1 "2025-08-16T00:14:23Z")

</div>

Is there a way I can exclude game objects like a hotbar, a health bar, some ui, and a points bar, from a camera shake?  
My shake code:

```javascript
this.cameras.main.shake(500, getRandomInt(3,15) / 1000)

```

I could in theory just write enemies.shake, player.shake, base.shake, etc. but that could become cumbersome even with a helper function.

Are there any workarounds?

Bread

🍞

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [August 16, 2025, 2:58pm UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/2 "2025-08-16T14:58:38Z")

</div>

You can use [multiple cameras in a scene (i.e., ignore)](https://phaser.io/examples/v3.85.0/camera/view/ignore) or [a separate UI scene](https://phaser.io/examples/v3.85.0/scenes/view/ui-scene).

---

<div class="post-metadata">

**Author:** ![Qugurun](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/qugurun/32/5132_2.png) [@Qugurun](https://phaser.discourse.group/u/Qugurun)\
**Post date:** [August 16, 2025, 6:57pm UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/3 "2025-08-16T18:57:18Z")

</div>

You can try using **`object.setScrollFactor(0);`** for your UI objects to avoid rewriting everything into separate scenes.

This will keep them fixed on the screen without needing to move them to a different scene.

---

<div class="post-metadata">

**Author:** ![bread](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bread/32/9050_2.png) [@bread](https://phaser.discourse.group/u/bread)\
**Post date:** [August 17, 2025, 8:16pm UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/4 "2025-08-17T20:16:22Z")

</div>

Thanks! I implemented the `UICam.ignore` and corresponding ui, but when the shake occurs (on enemy hitting the base), it seems to have created another set of the ui, which it _doesnt_ shake, but the original ui underneath it still does. This leads to a weird double effect which isn’t entirely bad, but isn’t the desired effect I’m looking for.

How would I go around fixing this?

This is how I use UICam:

```javascript
const UICam = this.cameras.add(0, 0, 800, 600);
UICam.ignore(hotbar, healthBars, moneyBars, hotbaritems, shopIcon, settingsIcon);

```

I can send a screenshot if you wish.  
No errors are being thrown.

🍞 B

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [August 18, 2025, 12:43am UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/5 "2025-08-18T00:43:47Z")

</div>

`ignore()` has exactly one argument. Change to

```javascript
UICam.ignore([hotbar, healthBars, moneyBars, hotbaritems, shopIcon, settingsIcon]);

```

---

<div class="post-metadata">

**Author:** ![bread](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bread/32/9050_2.png) [@bread](https://phaser.discourse.group/u/bread)\
**Post date:** [August 31, 2025, 1:05am UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/6 "2025-08-31T01:05:21Z")

</div>

I changed it as you’d shown but it still makes the doubling effect.

 ![](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/2/2f819a1a04c974e0df46b9bd72d582eb5e373745.png)

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [September 1, 2025, 6:16pm UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/7 "2025-09-01T18:16:35Z")

</div>

Make sure every value in `ignore([])` is a game object (can be a Container or Layer). Or if you have arrays of game objects, use spread:

```
UICam.ignore([...goldBars, ...candyBars])

```

> **[Shake main camera only Phaser Sandbox Entry](https://phaser.io/sandbox/euuwjnbY)**

---

<div class="post-metadata">

**Author:** ![bread](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bread/32/9050_2.png) [@bread](https://phaser.discourse.group/u/bread)\
**Post date:** [September 1, 2025, 11:30pm UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/8 "2025-09-01T23:30:29Z")

</div>

I `.push` game objects on a repeating function into groups\[1\] to make my bars, like `var newBar = healthBars.create(xPos,yPos,"health_box")`. When I use spreads (`[...healthBars]`) it gives me the err `healthBars is not iterable`.

Here’s the full code:

```javascript
// SHAKE IGNORE
const UICam = this.cameras.add(0, 0, 1200, 1000);
UICam.ignore([hotbar, ...healthBars, ...moneyBars, ...hotbaritems, shopIcon, settingsIcon]);

```

Am I simply using the wrong syntax? I haven’t used spreads before, lol

Thanks for your help,  
🍞

* * *

1. hotbaritems = this.physics.add.group();

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [September 2, 2025, 1:11am UTC](https://phaser.discourse.group/t/camera-shake-exceptions/15459/9 "2025-09-02T01:11:18Z")

</div>

Actually I was wrong and you can pass arrays or groups to `ignore()`, so you don’t need spreads.

You’ll need to use `ignore()` twice, once for each camera, to split all the game objects between the two cameras.
