Phase 2: PowerUps Destroyed by the Enemy
Objective: Give the Enemies the ability to detect if a PowerUp Collectable is in front of them and the ability to fire a laser to destroy before the player can collect.

First I will create a layer for the powerups, this will be used in the RayCasthit2D.

I will created a method called CheckForPowerUps(). This will check for anything on the powerup layer, using the RayCasthit2D. If a powerup is detected the FireLaser() Method will be called.

I will add the CheckForPowerUp() Method to the update Method.

Let’s see this in action

Happy Coding!