# Issue with Camera setBounds & follow player

**URL:** <https://phaser.discourse.group/t/issue-with-camera-setbounds-follow-player/8251>\
**Category:** Phaser 3\
**Created:** [November 30, 2020, 8:01pm UTC](https://phaser.discourse.group/t/issue-with-camera-setbounds-follow-player/8251 "2020-11-30T20:01:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![XXXiV-QN](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/xxxiv-qn/32/4410_2.png) [@XXXiV-QN](https://phaser.discourse.group/u/XXXiV-QN)\
**Post date:** [November 30, 2020, 8:01pm UTC](https://phaser.discourse.group/t/issue-with-camera-setbounds-follow-player/8251/1 "2020-11-30T20:01:48Z")

</div>

I am creating an “underwater diving game” where the backgrounds are set to repeated tileSprite, and players can swim up with key presses.

I managed to make camera follow my player with:  
`this.cameras.main.startFollow(this.player.sprite);`

However, when I try to set bounds for avoiding the display going into “black space”, the outcome is either camera no longer follows the player, or it displays a strange sizing portion between the background and rest of black space.  
`this.cameras.main.setBounds(0,0, config.width, config.height);`

My problem may due to the following misunderstandings:

- my lack of knowledge in setting up the background properly
- not specifying bounds in pixel? (I also don’t know how to convert background size to pixel)
- not understanding the setOrigin() method of backgrounds/sprite

My ultimate goal is to have a long background (width:height = 1:4), and the player can start at any random location within that background while the camera follows the player when it’s swimming up.

Any ideas or suggestions will be appreciated!

---

<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:** [December 1, 2020, 4:06pm UTC](https://phaser.discourse.group/t/issue-with-camera-setbounds-follow-player/8251/2 "2020-12-01T16:06:54Z")

</div>

> [@XXXiV-QN](#):
>
> or it displays a strange sizing portion between the background and rest of black space.

What does this look like?

---

<div class="post-metadata">

**Author:** ![XXXiV-QN](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/xxxiv-qn/32/4410_2.png) [@XXXiV-QN](https://phaser.discourse.group/u/XXXiV-QN)\
**Post date:** [December 1, 2020, 4:14pm UTC](https://phaser.discourse.group/t/issue-with-camera-setbounds-follow-player/8251/3 "2020-12-01T16:14:28Z")

</div>

I tried again this morning with the same camera code, and it worked. So it seems like it was the problem with origin setting of the background, and I was placing player outside of the background (so the camera moves with the player hence showing half the image background and half the default black background)

🤔

---

<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:** [December 1, 2020, 5:55pm UTC](https://phaser.discourse.group/t/issue-with-camera-setbounds-follow-player/8251/4 "2020-12-01T17:55:30Z")

</div>

> [@XXXiV-QN](#):
>
> However, when I try to set bounds for avoiding the display going into “black space”, the outcome is either camera no longer follows the player […]

That part is normal, as the camera can’t leave the bounds even while following a target.
