# How can i get each particle emitted

**URL:** <https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681>\
**Category:** Phaser 3\
**Created:** [December 18, 2022, 7:45am UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681 "2022-12-18T07:45:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![John4650-hub](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/john4650-hub/32/5786_2.png) [@John4650-hub](https://phaser.discourse.group/u/John4650-hub)\
**Post date:** [December 18, 2022, 7:45am UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681/1 "2022-12-18T07:45:41Z")

</div>

I need to get each alive particle, add physics to it then attach a  
collision callback to test if the particle is alive and coliiding with  
my gameObject.  
I have done something like this but its not working

```javascript
gemEmitter.forEachAlive(function(particle,gemEmitter){
        this.physics.add.existing(particle)
},this);

```

Then when i turn on the debugger, the particles have no body.

---

<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 18, 2022, 11:59am UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681/2 "2022-12-18T11:59:35Z")

</div>

Have you tried something like [death zone from arcade body](https://labs.phaser.io/edit.html?src=src%5Cgame%20objects%5Cparticle%20emitter%5Cdeath%20zone%20from%20arcade%20body.js)?

---

<div class="post-metadata">

**Author:** ![John4650-hub](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/john4650-hub/32/5786_2.png) [@John4650-hub](https://phaser.discourse.group/u/John4650-hub)\
**Post date:** [December 18, 2022, 3:08pm UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681/3 "2022-12-18T15:08:30Z")

</div>

@samme  
I have, but it doesn’t seem to be what i want to do. I looked at every  
example about particles but none showed how to get a single  
emitted particle yet in the API it’s mentioned.

---

<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 18, 2022, 4:53pm UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681/4 "2022-12-18T16:53:45Z")

</div>

https://codepen.io/samme/embed/preview/jOpOOqa?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=jOpOOqa

---

<div class="post-metadata">

**Author:** ![John4650-hub](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/john4650-hub/32/5786_2.png) [@John4650-hub](https://phaser.discourse.group/u/John4650-hub)\
**Post date:** [December 20, 2022, 7:36am UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681/5 "2022-12-20T07:36:29Z")

</div>

@samme  
it worked. but now the bodies are displaced from their parent particles  
Here is what i have so far.

```javascript
let gem = this.add.particles('gem').setScale(.1);
    let gemEmitter = gem.createEmitter({

      x: this.scale.width / 0.18,
      y: this.scale.height / .23,
      frequency: 1000,
      quantity: { min: 1, max: 2 },
      alpha: 1,
      tint: 0x00ff00,
      followOffset: {
        x: 0,
        y: 0
      },
      emitCallback: (p)=>{
        if(p.body) return;
        var { width, height, halfWidth, halfHeight } = p.frame;
        
        p.hasTransformComponent = true;
        p.displayWidth = width;
        p.displayHeight = height;
        p.width = width;
        p.height = height;
        p.displayOriginX = halfHeight;
        p.displayOriginY = halfHeight;
        this.physics.add.existing(p);
        p.body.moves = false;
      },
      emitCallbackScope:this
      ,
      lifespan: 50000,
      speed: { min: 500, max: 1000 },
      maxVelocityX: 200,
      maxVelocityY: 500,
      blendMode: 'ADD'
    });
  
  
  this.player = this.physics.add.image(40, 40, 'ply').setOrigin(0).setScale(.08);
  /** Overlap*/
   this.physics.add.overlap(this.player, gemEmitter.alive);

```

---

<div class="post-metadata">

**Author:** ![John4650-hub](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/john4650-hub/32/5786_2.png) [@John4650-hub](https://phaser.discourse.group/u/John4650-hub)\
**Post date:** [December 20, 2022, 9:02am UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681/6 "2022-12-20T09:02:08Z")

</div>

![Screenshot_20221220-115202](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/0/03b71c03e03b8bd19c114b69711ddad9075b6c42.png)  
There’s a large body moving randomly on the screen

---

<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 20, 2022, 2:31pm UTC](https://phaser.discourse.group/t/how-can-i-get-each-particle-emitted/12681/7 "2022-12-20T14:31:19Z")

</div>

I think you have to avoid scaling the particle manager.

You could scale the particles if you adjust the width, height, and origin values.
