# How to collide group with itself and each children push back the other

**URL:** <https://phaser.discourse.group/t/how-to-collide-group-with-itself-and-each-children-push-back-the-other/7181>\
**Category:** Phaser 3\
**Created:** [August 14, 2020, 9:58am UTC](https://phaser.discourse.group/t/how-to-collide-group-with-itself-and-each-children-push-back-the-other/7181 "2020-08-14T09:58:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [August 14, 2020, 9:58am UTC](https://phaser.discourse.group/t/how-to-collide-group-with-itself-and-each-children-push-back-the-other/7181/1 "2020-08-14T09:58:42Z")

</div>

Hi,  
i want to create two or more sprite maybe at the same location with arcade physics and i want that each member push back the other… i try without success.

I made a jsffidle about that :

[https://jsfiddle.net/espace3d/1nps402y/](https://jsfiddle.net/espace3d/1nps402y/)

```
var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    backgroundColor: '#1b1464',
    parent: 'phaser-example',
    physics: {
        default: 'arcade',
        arcade: {
            gravity: {
                x: 0,
                y: 100,
            },
        debug:true,
        }
    },
    scene: {
        preload: preload,
        create: create,
        update: update

    }
};

var game = new Phaser.Game(config);
var o={};
function preload ()
{
	this.load.image("block", "https://i.postimg.cc/KvY7DVGx/player.png");
}

function create ()
{
o.g = this.physics.add.group()

o.e = this.physics.add.sprite(100,100,"block").setBounce(1,1)
o.f = this.physics.add.sprite(140,120,"block").setBounce(1,1)

o.g.add(o.e)
o.g.add(o.f)
this.physics.add.collider(o.g, o.g);

}
function update ()
{
 
}

```

Could you help me please ?  
Thanks.

---

<div class="post-metadata">

**Author:** ![BlunT76](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/blunt76/32/1454_2.png) [@BlunT76](https://phaser.discourse.group/u/BlunT76)\
**Post date:** [August 15, 2020, 9:16am UTC](https://phaser.discourse.group/t/how-to-collide-group-with-itself-and-each-children-push-back-the-other/7181/2 "2020-08-15T09:16:57Z")

</div>

Hi,  
Sprites bodies can’t collides if they already overlaps, so you can’t start at the same position at the same time. Here’s a working example:

```javascript
var game = new Phaser.Game(config);

function preload ()
{
	this.load.image("block", "https://i.postimg.cc/KvY7DVGx/player.png");
}

function create ()
{
this.g = []

this.e = this.physics.add.sprite(100,100,"block").setBounce(1,1)
this.f = this.physics.add.sprite(140,200,"block").setBounce(1,1)

this.e.body.setCollideWorldBounds(true)
this.f.body.setCollideWorldBounds(true)

this.g.push(this.e)
this.g.push(this.f)
this.physics.add.collider(this.g, this.g);

}
function update ()
{
 
}

```
