Taking Player Powerups away! More enemy AI advancement.

We’ve given 6 powerups to the player to help him combat enemy AI. So what happens if we take it away? What happens if the enemy, who I might add is growing smarter every article I write, decides that it can “see” the powerups? What happens if it can see the powerups AND decide to blow them up?


So that’s what I did. I gave the enemy AI even more brains. Now while it is travelling down it is sending out a “radar” of sorts and if it stumbles across a powerup, BOOM.. it takes it out.

If you read my last article where I gave 1 enemy the ability to fly to the bottom of the screen, stop and then go back and forth and fire whenever it detected the player in front of it then this won’t be too difficult.

In fact, it was pretty much a copy/paste (don’t tell my boss).

First, I created an agroRange variable that would hold the length that we want the enemy to be able to see. I then called the functions I create below in the update function:

Then, I went and created the functions that would help the enemy see and fire when the powerups where in line.

Ok, so all I did here was created (see: copied) a function like I did with the player detecting enemy. Had to change a few things though. You can see how I did this in the last article here:

Firstly, in the endPos I had to change the Vector3 to down as it is the enemy flying down. Then I created a FireLasersAtPowerup() that is called whenever the enemies raycast comes across the Powerup tag. Don’t forget to change all of your powerups tags.

So when the enemies “radar” shows a powerup in front of it it will run the above code. Basically just the normal enemy lasers except I got rid of the random.range and allowed the enemy to fire here when it needed too.

Let’s look how this plays out. I just made a “test” start and put a bunch of enemies behind the powerups.

Oh man, that’s nasty. You are going to have some angry players waiting to line up that one health powerup only to have it blown away.

Tomorrow, it’s a toss up between giving the player the power to press C and have the powerups magnetize towards him, or working even deeper with our enemy AI and give them the ability to dodge player laser!

Happy Clicking!




With Unity all can be accomplished!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Can Artificial Intelligence Solve The Challenges Of Talent Assessment?

What is Artificial Intelligence?

Introduction of AI to New-Age Human Resource

Bot Designers, Developers & Marketers: Champ Bot Review

The Future of AI Ethics: Blockchain

Will Harsh Economic Times Cause an AI Spillover ?

The Future of Music or: How I Learned to Stop Worrying and Love Artificial Intelligence.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Laine Dorchester

Laine Dorchester

With Unity all can be accomplished!

More from Medium

Connecting GitHub to Unity

Unity : AI [Navmesh implementation (Part IV)]

Sphere Scene in Unity URP

Use NuGet packages with Unity