I'm making a shooter game in phaser 3, and I'm wondering if there is a way to cast a ray from a game object in one direction using either an angle or two pairs of coordinates, maybe like this?
this.ray = this.physics.add.ray(this.player.x, this.player.y, this.pointer.worldX, this.pointer.worldY);
this.physics.add.collider(this.ray, this.someEnemy, () => {
alert("you hit something!")
})
or maybe like this?
this.ray = this.physics.add.ray(this.player.x, this.player.y, Phaser.Math.RAD_TO_DEG * Phaser.Math.Angle.Between(this.player.x, this.player.y, pointer.worldX, pointer.worldY);)
this.physics.add.collider(this.ray, this.someEnemy, () => {
alert("you hit something!")
})