Hi Guys
I'm working on a top down shooter. I have AI that uses angleBetween to face the direction of enemies when they spawn.
The game uses a tilemap with some collisions randomly spawned around the map.
Is there a way that I can detect if there's a collision layer blocking the path between my AI and enemy sprites?
I don't want my AI to mindlessly fire their weapon if the enemy is behind a wall.
in my AI.js I have:
AI.Prototype.update = function() {
...
this.rotation = game.physics.arcade.angleBetween(this, this.closestEnemy);
...
**Checks if enemy exists on map, uses Phaser weapon plugin**
this.pistol.fire();
};
Would I need to implement pathfinding to check if there's a direct path before firing or is there an easier way to go about this?