# Collision problem

**URL:** <https://phaser.discourse.group/t/collision-problem/3074>\
**Category:** Phaser 3\
**Created:** [July 11, 2019, 12:59pm UTC](https://phaser.discourse.group/t/collision-problem/3074 "2019-07-11T12:59:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Faizan\_Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/faizan_ali/32/964_2.png) [@Faizan\_Ali](https://phaser.discourse.group/u/Faizan_Ali)\
**Post date:** [July 11, 2019, 12:59pm UTC](https://phaser.discourse.group/t/collision-problem/3074/1 "2019-07-11T12:59:58Z")

</div>

My tank shoots an enemy tank and only destroys the body without destroying the turret aswell. I want the tank body and the turret to destroy not just the enemy tank body.  
Here is my code:

class Enemy extends Phaser.Physics.Arcade.Sprite {

```
constructor(scene, x, y, texture) {
    super(scene, x, y, texture = 'player2', 'tank1')
    scene.add.existing(this);
    scene.physics.add.existing(this);
    scene.events.on('update', this.update, this);
    scene.physics.world.enableBody(this, 0);

    this.setOrigin(0.5, 0.5);
    this.setCollideWorldBounds(true);
    this.body.setVelocity(100, 0);
    this.body.bounce.setTo(1, 1);
    this.health = 3;
    //this.bullets = bullets;
    this.fireRate = 1000;
    this.nextFire = 0;
    this.alive = true; 
    this.tank = this.scene.tank;
                

    this.turret = new turret(scene);
    this.shadow = new shadow(scene);
    
    
}

update(keys, time, delta) {

    
    function enemyDestroy(Enemy, bulletHit)
    {
        if (bulletHit.active === true && Enemy.active === true)
        {
            Enemy.health = Enemy.health - 1;
            console.log('enemy hp:', Enemy.health);

            if (Enemy.health <= 0)
            {
                Enemy.setActive(false).setVisible(false);                                
                                             
                
            }                

            bulletHit.setActive(false).setVisible(false);
        }
    }
    

    this.turret.follow(this);
    this.shadow.follow(this);

    this.scene.physics.world.collide(this, player);
    this.scene.physics.world.collide(this, playerBullets, enemyDestroy);
           
        
    
    
    
    
}

```

}

class turret extends Phaser.GameObjects.Sprite {  
constructor(scene, x, y, texture) {  
super(scene, x, y, texture = ‘player2’, ‘turret’)  
scene.add.existing(this);  
scene.events.on(‘update’, this.update, this);

```
    this.setOrigin(0.3, 0.5);
}

follow(tank) {
    this.setX(tank.x);
    this.setY(tank.y);
}

update() {

    
    
    this.rotation = Phaser.Math.Angle.Between(this.x, this.y, player.x, player.y);

    
    
    
    
    
    
}

```

}
