How bosses and enemies decide what to do in video games
Unity Team - Unity Technologies

A beginner’s guide to how enemy AI works in video games: states, senses, telegraphed attacks, and boss phases, plus how designers keep enemies fair and fun.
A guard walks the same route until they hear a noise. A monster winds up a huge swing before it lands. A boss suddenly changes tactics halfway through a fight. If you play games, you’ve seen enemies make decisions like these thousands of times. But how does an enemy actually “decide” anything?
This guide explains how enemy AI works in video games, from simple patrolling guards to multi-stage boss fights. You don’t need any programming knowledge. Once you understand the basic patterns, you’ll be able to describe the enemies you want in your own game – and you’ll start noticing these patterns in every game you play.
First, what is “enemy AI” in video games?
When game makers talk about enemy AI, they usually don’t mean the kind of AI that writes text or generates images. Enemy AI is the set of rules that controls how a character behaves: when it moves, what it notices, and how it reacts. These rules are designed and written by game makers ahead of time.
A useful way to think about it is a simple loop: the enemy senses what’s around it, thinks about what to do, and then acts. That loop repeats over and over while you play.
States: the simplest way enemies make decisions
The most common way to organize enemy behavior in video games is to break it into states. A state is a mode the enemy is in, like patrolling, investigating, or attacking. An enemy is only in one state at a time, and it switches to a new state when certain conditions are met.
Here’s a classic example of a castle guard:
- Patrol: The guard walks their route and keeps watch.
- Investigate: If they hear a noise, they go check it out, then return to patrolling if they find nothing.
- Attack: If they see an intruder at any point, they attack.
- Flee: If their health drops too low during a fight, they run away.
That’s it. Four states and a handful of rules, and you have an enemy that feels like it’s reacting to you. This approach is popular partly because it’s easy to sketch out: each state is a box, and each rule for switching between states is an arrow. Sketching these diagrams before building anything helps make sure the behavior makes sense.
Other ways enemies choose what to do in video games
States aren’t the only approach. Two others are worth knowing about:
- Priority lists: The enemy checks a list of possible behaviors in order of importance and does the first one that applies. For example, “If I’m badly hurt, retreat. Otherwise, if I can see the player, attack. Otherwise, patrol.” Game makers often organize these as a branching structure called a behavior tree.
- Weighing options: Instead of yes-or-no rules, the enemy gives each possible action a score based on the situation – how hurt it is, how far away the player is, how much ammo it has – and picks the most appealing option. This can make characters feel more natural and less robotic, but it also makes them less predictable.
For most games, especially your first, simple states are plenty.

Clean, flat two-panel diagram titled “How enemies choose what to do,” light gray background. Left panel, “Priority list: the first match wins”: a vertical flowchart with three numbered question boxes connected by “No” arrows. Each box has a “Yes” arrow to a colored action box: Retreat (red), Attack (orange), Patrol (blue). Right panel, “Weighing options: the highest score wins”: three gray pill-shaped factor tags above three horizontal bars for Attack, Retreat and Patrol. The longest bar is Attack, highlighted orange and tagged “Chosen.” Inter font, minimal style. Image generated by Claude Opus 5.5, October 26, 2026.
How enemies notice you
Before an enemy can react to you, it has to notice you. Games usually give enemies simplified senses.

Clean, flat educational diagram titled “How enemies notice you,” light gray background. Left: top-down view of a red enemy circle with a translucent orange vision cone. A dark wall blocks part of the cone. One blue player circle is visible inside the cone and another is hidden behind the wall. A dashed circle around the enemy shows hearing range, with a small footsteps icon inside it. Right: three stacked cards labeled Unaware, Suspicious and Spotted, each with a colored icon and a progress meter filling from empty to full. Inter font, minimal style, no characters or game screenshots. Image generated by Claude Opus 5.5, October 26, 2026.
Sight
Many games give enemies a vision cone: an area in front of them where they can see. If you’re inside it and not hidden behind something, they start to notice you.
Hearing
Sounds can have a range. If an enemy is within range of a sound, like footsteps or a door opening, it hears it and reacts.
Awareness levels
Noticing isn’t always instant. Many games use levels of awareness: the enemy hasn’t noticed anything, then it notices something and comes to investigate, then it fully spots you. Games often show this with a meter or icon that fills up, giving you a window to hide before you’re caught. Enemies may also call out short voice lines – like “Did you hear that?” – so you understand what they’re reacting to.
What matters is what feels fair
Here’s a key lesson from game makers: It doesn’t matter what an enemy should be able to see or hear in real life. What matters is what the player thinks the enemy can see or hear. Getting spotted by an enemy you couldn’t see can feel unfair, even if it makes perfect sense. In one case, making off-screen enemies hear a bit less made the game instantly more fun.
Telegraphing: why enemies warn you before they attack
Have you noticed that enemies often pull back, glow, or make a sound right before an attack? That’s called telegraphing. Telegraphing in video games is a design technique where a game gives players a visual, audio, or animation cue before an enemy, boss, or hazard attacks. The cue gives players a fair window to react by dodging, blocking, parrying, or countering. Common telegraphs include a wind-up animation, a glowing attack indicator, a warning sound, or a ground marker showing the attack’s area.
The word comes from sports like martial arts, where a fighter’s body language can give away their next move. Real fighters try to hide those signals. Game enemies do the opposite: they show you what’s coming so you can respond.
A short delay before an attack is what makes it fair. If you know the hit is coming and still get caught, you understand why – and you know what to do better next time. These warnings don’t have to be cartoonish or overexaggerated. In a more realistic game, a single sound and a small movement can be enough.
Keep the signals consistent
Telegraphs only work if they always mean the same thing. If a red glow means “you can’t block this,” then every red-glowing attack should be unblockable, no matter what enemy uses it. It also helps when the damage matches how dangerous an attack looks. Losing half your health to a tiny jab feels unfair, while losing it to a giant ground-shaking slam feels earned.
How bosses are built in video games
A boss is more than a big enemy with lots of health. One helpful way to think about a boss fight is that it’s both a test and a story.
A boss is a test
A boss tests the skills the player has learned so far. A simple way to design a video game boss is to:
- List the skills you want to test, like jumping, dodging, or blocking.
- Come up with attacks that test each skill. For example, a shockwave that rolls across the ground tests jumping.
- Decide how those attacks fit the boss’s look and personality.
- Give the boss a way to defend itself, so players can’t just stand there and win without being tested.
A boss is a story
Boss fights also tend to follow a story-like shape, with a beginning, middle, and end. A common boss structure in video games looks like this:
- Build-up: The game hints at the boss before you meet it and teaches you the skills you’ll need.
- Introduction: The boss makes a dramatic entrance.
- The basics: The boss uses its simplest attacks, so you can learn its patterns.
- Escalation: New attacks and complications appear.
- A twist: A midpoint surprise, like a transformation or a false victory, raises the stakes.
- Full intensity: The boss uses everything it has.
- Defeat and reward: The boss goes down in style, and the player gets a moment to feel great.

Clean, flat line chart titled “How a boss fight builds,” light gray background. The x-axis is Time and the y-axis is Intensity. A smooth black line passes through seven colored dots labeled Build-up, Introduction, The basics, Escalation, A twist, Full intensity, and Defeat and reward. It rises to a peak at Full intensity, then drops. Two shaded vertical bands are labeled “Phase 1: learn the patterns” and “Phase 2: new tricks, same rules.” A dark gray note at the bottom says to make the fight harder, not harder to read. Inter font, minimal style. Image generated by Claude Opus 5.5, October 26, 2026.
Boss patterns and phases
Bosses repeat patterns, and players learn to recognize them over time. Recognizing a pattern until it becomes second nature takes mental effort, which is part of why beating a tough boss feels so satisfying.
To make a fight harder without making it unfair, game makers change things up after players have learned the basics, often by switching to a new phase. They might chain patterns together, change their timing, shorten the windows where the player can strike back, speed things up, or add a second enemy. What they avoid is making attacks harder to read.
Smart enemies vs fun enemies
You might assume the best enemy is the smartest one. It isn’t. Game makers aim for enemies that are fair, consistent, easy to read, and believable. An enemy doesn’t need to be brilliant – but fighting them shouldn’t be a cakewalk, either.
Consistency matters most here. Players need to predict roughly how an enemy will react, so they can make a plan and get better. Predictable doesn’t mean repetitive, though. An enemy can react at the same distance and speed every time while still using different animations and voice lines.
Describe your own video game enemies
When you plan an enemy for your game, try answering these questions:
- What does it do when it hasn’t noticed the player?
- How does it notice the player – sight, sound, or both?
- What does it do once it’s noticed them?
- How does it warn the player before it attacks?
- When does it give up, retreat, or change tactics?
If it’s a boss, add:
- Which skills is this fight testing?
- How does the fight change as it goes on?
Answering these gives you a clear, complete picture of your enemy before you build anything.
Rules that feel alive
Enemies in games aren’t really thinking. They’re following rules designed to feel like thinking. The best ones are fair, readable, and consistent, so every win feels earned and every loss feels like a lesson. Start simple, give your enemies clear signals, and let players learn to outsmart them.
Ready to tackle your first boss fight? You don't need to be a developer. Try Unity Spark, Unity's browser-based, AI game creation platform that allows you to describe your game, refine it in a real web editor, and publish it for others to play.
Header image note: A loop of four states (patrol, investigate, alert, flee), with the alert state glowing. Image generated by Claude Opus 5.5, October 7, 2026.