# \[Solved\] Issue with creating a pool of disabled objects (body is enabled but shouldn't)

**URL:** <https://phaser.discourse.group/t/solved-issue-with-creating-a-pool-of-disabled-objects-body-is-enabled-but-shouldnt/9987>\
**Category:** Phaser 3\
**Created:** [July 20, 2021, 12:35pm UTC](https://phaser.discourse.group/t/solved-issue-with-creating-a-pool-of-disabled-objects-body-is-enabled-but-shouldnt/9987 "2021-07-20T12:35:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![piotr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/piotr/32/4698_2.png) [@piotr](https://phaser.discourse.group/u/piotr)\
**Post date:** [July 20, 2021, 12:35pm UTC](https://phaser.discourse.group/t/solved-issue-with-creating-a-pool-of-disabled-objects-body-is-enabled-but-shouldnt/9987/1 "2021-07-20T12:35:09Z")

</div>

Hi all,

What I want is to create a pool of 30 projectiles at the cannon’s location, the projectiles should be hidden and their bodies disabled. Then when one bullet is fired, its visibility and its body should be enabled.

I managed to do all of this, the only issue I have is that the player collides with the 30 bullets hidden at the cannon’s location. I assume their bodies aren’t properly disabled (visibility is).

In Play.js create multiple cannons from Tiled objects

```javascript
createCannons() { 

	this.bulletsLayer.forEach(object => { 
			var bulletGroup = new BulletGroup({
					'world': this.physics.world,
					'scene': this,
	     			 'x': object.x,
	     			 'y': object.y,
				}); 
				
			this.physics.add.overlap(this.player, bulletGroup, this.onBulletHitPlayer, false, this);
		});
	}

```

BulletGroup.js

```javascript
import Bullet from "../prefabs/Bullet.js"

export default class BulletGroup extends Phaser.Physics.Arcade.Group
{
	constructor(settings) {

    this.createMultiple({
			classType: Bullet,
			frameQuantity: 30,
			active: false,
			visible: false,
			...
		});
     }

    fireBullet()
	{
		const bullet = this.getFirstDead();
		if (bullet) {
			bullet.fire();
		}
	}
}

```

Bullet.js

```javascript
export default class Bullet extends Phaser.Physics.Arcade.Sprite
{
    constructor (scene,x,y,key,frame)
    {
        super(scene,x,y,key,frame);
        scene.add.existing(this); 
        //the code below doesn't solve the issue
       // this.scene.physics.world.enable(this); //allow physics to move the container and its child
        // this.body.setSize(5, 5, true);
        // this.setActive(false);
        // this.setVisible(false);
        // this.body.enable = false;
    }

fire()
    {
        this.scene.physics.world.enable(this); //allow physics to move the container and its child
        this.setActive(true);
        this.setVisible(true);
        this.body.enable = true;
        this.body.setSize(5, 5, true);
        //...
}

```

---

<div class="post-metadata">

**Author:** ![piotr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/piotr/32/4698_2.png) [@piotr](https://phaser.discourse.group/u/piotr)\
**Post date:** [July 20, 2021, 12:45pm UTC](https://phaser.discourse.group/t/solved-issue-with-creating-a-pool-of-disabled-objects-body-is-enabled-but-shouldnt/9987/2 "2021-07-20T12:45:29Z")

</div>

Also adding ‘enable: false’ to createMultiple, doesn’t help

```javascript
this.createMultiple({
			classType: Bullet, 
			frameQuantity: 30, 
			active: false, 
			visible: false, 
			enable: false, // <- doesn't help neither
		});

```

---

<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:** [July 20, 2021, 3:19pm UTC](https://phaser.discourse.group/t/solved-issue-with-creating-a-pool-of-disabled-objects-body-is-enabled-but-shouldnt/9987/3 "2021-07-20T15:19:50Z")

</div>

`enable` must be in [PhysicsGroupConfig](https://newdocs.phaser.io/docs/3.52.0/Phaser.Types.Physics.Arcade.PhysicsGroupConfig), e.g.,

```js
class BulletGroup extends Phaser.Physics.Arcade.Group
{
  constructor(settings) {
    super(settings.world, settings.scene, { enable: false });
    // …
  }
}

```

> [@Bullet pools (Phaser 3)](https://phaser.discourse.group/t/bullet-pools-phaser-3/7502):
>
> [Space battle 480x480] A bullet pool is a [sprite pool](https://phaser.discourse.group/t/arcade-sprite-pool/1209) where all the sprites are initially inactive. They are activated when fired and then deactivated when they collide or expire. Bullet pools Bullet pools with extended game object class More examples

---

<div class="post-metadata">

**Author:** ![piotr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/piotr/32/4698_2.png) [@piotr](https://phaser.discourse.group/u/piotr)\
**Post date:** [July 20, 2021, 6:29pm UTC](https://phaser.discourse.group/t/solved-issue-with-creating-a-pool-of-disabled-objects-body-is-enabled-but-shouldnt/9987/4 "2021-07-20T18:29:50Z")

</div>

Thank you! That solved it!
