Bullets collide with tiles [SOLVED]

Im trying to destroy bullets on collision with my tiles, but all callbacks seems to be null.

this.physics.add.collider(groundLayer, this.weapon.bullets, this.collideCallback, this.processCallback, this);

Can anyone help me on how to destroy bullets when they hit my groundlayer?

var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
physics: {
default: ‘arcade’,
arcade: {
gravity: {y: 500},
debug: false
}
},
scene: {
key: ‘main’,
preload: preload,
create: create,
update: update
},
};

My bad, got the callback working

this.physics.add.collider(groundLayer, this.weapon.bullets, collideCallback(), processCallback(), this);

But it is only called when the game inits.

How can I kill the bullets that hit the tiles?

Fixed it.

function create() {

this.physics.add.collider(this.weapon.bullets, groundLayer, bulletCollide, null, this);

}

function bulletCollide (bullet, groundLayer) {
bullet.kill();
}

1 Like