Making Enemies That Try And Dodge The Player’s Attacks

In a lot of games, you will encounter enemy AI that detects the player’s actions and tries to counter them. In Halo if you throw a grenade, the Elite enemy type will attempt to dive out of the way in order to avoid taking damage. So what would that logic look like?

In order for an enemy to react, they will need some sort of trigger to react to. In this case, I am using the same colliders that I used/addressed in a previous article for enemies to detect powerups that are in front of them. I then just added an alternative method that is called in Update instead of the regular movement calculations if a laser is detected in front of them.

--

--

--

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

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

Recommended from Medium

Audiences & Experiences Week #11

[GUIDE] How to Get Out of Bronze or Silver in League of Legends

E3 2017 Bold Predictions Extravaganza

Humble Bundle is a Bundle of Fun!

Remember when Rocket League developer Psyonix wanted cross-play on PS4?

Pocket Towne

State of the Stream Q4/19: Just Chatting takes the #1 spot for the first time, Facebook Gaming…

PSN download speeds to be throttled in the United States as well

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
Adam Reed

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

More from Medium

Trigger collisions

New Input System and UI

A Series On Creating Immersive Audio in Unity with Custom Wwise Scripts

It began with a 2D Space Shooter