# Adding physics body to a group

**URL:** <https://phaser.discourse.group/t/adding-physics-body-to-a-group/6415>\
**Category:** Phaser 3\
**Created:** [May 24, 2020, 8:52am UTC](https://phaser.discourse.group/t/adding-physics-body-to-a-group/6415 "2020-05-24T08:52:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericHgorski](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@ericHgorski](https://phaser.discourse.group/u/ericHgorski)\
**Post date:** [May 24, 2020, 8:52am UTC](https://phaser.discourse.group/t/adding-physics-body-to-a-group/6415/1 "2020-05-24T08:52:58Z")

</div>

I am making a game where a chicken is dropping eggs from the sky. However I am having trouble getting the eggs to ‘fall’. I added it as a group with physics enabled. But I cant seem to get the ‘body’ property to come back as anything as null. Here is the relevant code:

class Egg extends Phaser.GameObjects.Sprite {  
constructor(scene) {  
var x = scene.chicken.x;  
var y = scene.chicken.y + 80;

```
    super(scene, x, y, "egg");

    // Add the egg to the scene
    scene.add.existing(this);
    this.play("egg_anim");

    // enable physics
    scene.physics.world.enableBody(this);

    this.body.velocity.y = -250;

    // Add the beam to the projectiles group in scene 2
    scene.projectiles.add(this);
}

```

}

And this is how I add it to the projectiles group:

```
    this.projectiles = this.physics.add.group();

```

thanks so much!

---

<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:** [May 24, 2020, 3:46pm UTC](https://phaser.discourse.group/t/adding-physics-body-to-a-group/6415/2 "2020-05-24T15:46:36Z")

</div>

👋

I tried this and the `body` part is working correctly, but the velocity is getting reset when you add it to the group. Do this instead:

```javascript
// enable physics
scene.projectiles.add(this);

this.body.velocity.y = -250;

```

---

<div class="post-metadata">

**Author:** ![ericHgorski](https://avatars.discourse-cdn.com/v4/letter/e/dbc845/32.png) [@ericHgorski](https://phaser.discourse.group/u/ericHgorski)\
**Post date:** [May 25, 2020, 1:00pm UTC](https://phaser.discourse.group/t/adding-physics-body-to-a-group/6415/3 "2020-05-25T13:00:52Z")

</div>

That got it to work, thanks so much!
