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

Babylon Recap: An Interview with Ege Kumlali of The Alchemist

Using asymmetry in game design

The Next Kawaii League Update Plan

A Dungeon Master’s Guide to DMing a Podcast

Review: Bus Simulator 18

Virtually Spaced

Paris Legion roster finally revealed for CDL 2021

img

«Our goal is to publish a great game, which will be well received all over the world» An interview…

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

OnCollisionEnter Vs. OnTriggerEnter — When to use them?

Mastering Unity Scripting | Summary — Chapter 2: Debugging

Overloading methods in C# & Unity

Creating MineField In Unity (Part 2)