How can you detect a collision between a group and a tilelayer in Phaser? A reason could be for example to delete bullets hitting a wall. In theory it is easy, just use a collider, but nothing works. I have tried overlap instead of collide, making the bullets a physics group, using world.addCollider, etc.
Some tiles have been set to collide with this following line:
this.groundLayer.setCollisionByProperty({ collides: true });
by getting the collide property from a JSON file produced by Tiled. So collision works fine between the player and the tiles.
The dysfunctional code is below:
this.physics.add.collider(
this.bullets,
this.groundLayer,
(bullet, tile) =>
{
console.log("hit");
bullet.setActive(false);
bullet.setVisible(false);
});