The Basics of Enemy Design
An Enemy can have up to 3 Senses. They are not like human senses, but the idea is kind of the same.
They can be rather complex or very simple. Each game is different so the enemy design in games has to be different every time you create a new game.
The Senses are as follows:
- Eye (Seeing something)
- Ear (Hearing something)
- Touch (Feeling ?)
- Pre-Set (or Non-Sense)
There extra’s which can literally be passed into the first 3.
Which are “Feeling something” and “Smelling something”. But as i said it’s not like in the real world.
There can also be “Mood” if you use different states or behaviors in which the enemy can be. This most of the time is relative to values like health.
This is a rather old sense, in which the enemy doesn’t do much but moving from Point A to Point B. That “Path” is usually set by hand or is based on Obstacles.
When using obstacles, the enemy needs to what to do when it “reaches” an obstacle. There are 2 common possibilities. You can give the enemy an Eye or a Touch Sense.
The Eye Sense
The first sense of an Enemy in Games is usually the “Eye”. In Unity we can use Raycasts to look forward or in any direction to “see” something. And The Raycast “sees” something we are looking for, the enemy can react to it. In my example change the move direction. We just need to make sure the raycast is not to long.
So what can the enemy “look” for?
- The Player/s of the Game
- Items or Collectibles
- Other Enemys
Based on “priority” and maybe some random or special factors, you can give the enemy a possiblity to react.
This can be factors like range, strength or other parameters you have to decide on your own. By creating a reaction board you can better design the enemy behavior, later on you can fine tune that reactions, times or even numbers.
So if the enemy has multiple option, you need to tell the enemy, maybe based on a difficulty setting, how the enemy should react once he has a scenario like above.
The enemy sees 4 Options, he can pick up an item, he can hide behind an obstacle, he can pick up a weapon, or can attack the player.
Decision making is hard to program, and if you are not using maschine learning, you have to pre-determine such scenarios.
How to do that is rather simple to do enemy design in games. You can simply weight importance and calculate chances to do the most weighted first.
A weight table could be like :
- weapon: (if better than current) 45% priority
- item: (if needed for something enemy relevant) 35% priority
- attack player: (if stronger than him) 15% priority
- obstacle: (if to weak to battle, player is way to strong) 5% priority
But the weight table can also be totally different or change, because of other behaviors which play a role. Again, you need to decide how you want the enemies to act. Don’t forget to pull in distance and speed parameters as well, like: Is the item even reachable, am i faster than the player?
The Ear Sense
Of course a an enemy is unable to hear, but you can put in items which have a event range to make every enemy nearby listen to that event. Like you step on a twig, or shoot. Also it can be an alarm, which you triggered. That can trigger events on enemies which are close enough and are able to listen to that event.
In such a case you can put the enemy into a different state, so he may look into the direction where he heard it, or runs around , trying to find the player for using the eye sense.
The Touch Sense
The touch sense, can be different from game to game, but you can see that sense like getting hit by something. In that case the enemy looses health or takes damage which is the most common use for that.
There are a bunch of possibilities to react to it. In a Boss Battle as an Example you can enrage the Boss at a specific health amount, and use total different behaviors, or even attacks the boss will perform.
The Smelling Sense
That is a sense which can be seen as the ear sense. If your player has a “Rose” smell you could react with the enemy in different behaviors.
The Pre-Set Sense
This is like the Non-Sense. An Enemy walks on a given path, not doing much but maybe idle here and there. Combined with the other senses it can be pretty powerful. Since it might still be able to hear something like a deer in the wood, can run in the opposite direction of the sound.
It maybe runs for 1 second and than continues with his route. But also it can react to touch, if you shoot the deer, or even can be enraged, if you hurt another deer nearby.
Enemy design in games can be rather complex, and you have to decide, what you really need, and what the enemy should do. So plan ahead, and try to use the easiest sense to get best effects.
Thanks for reading.