Ok so we have it setup for our enemies to fire now, but those lasers don’t hurt our player at all. That’s no fun so let’s fix it. One way to handle this is to simply setup the laser to trigger the player’s damage method. This can be done many ways but I find just using a Trigger Collision check to be simple and easy. On the laser script.
It’s that simple now our enemy laser should trigger the damage of our player.
If you’ve been following along you’ll notice something quite odd is happening. Our dead enemies are still firing!!!
Well we certainly need to fix that. This is pretty easy to do. We can add a bool check on the enemy.
We need to make sure to check for this when trying to fire.
Now all we need to do is change this when dying.
That’s it! Now our enemy will no longer fire more lasers once it’s dead.