Specialization and background
With my specialization at TGA I decided to do something similar to the AI Director that Left 4 Dead has.
AI within games has always been there but every now and then we get cool concepts such as the AI Director for L4D. Something which I adore about video games are when they introduce complexity through simple means. A simple thing as not spawning in enemies in a linear way can do so much. A newer game which added fuel to the fire is Helldivers 2, once again we see how AI can add so much to the overall game experience for the player. With all this said what is an AI Director? In short it is something which directs the AI, this could be manipulating spawn positions, creating strategies to defeat the player, basically something which pulls the AI to do stuff.
Why AI Director?
I wish to delve deeper into the world of directors and AI to deepen my understanding of what's possible. I love gameplay and an area which I feel can be utilized more is just this. That is why I'm putting all my effort into this to one day help innovate the space.
Enemy spawn
Enemies will always spawn around the player and will try their best to be outside view.
Relax Ramp
The game starts out with a relax state followed quickly by the ramp state. We can see how a couple of enemies spawn.

Ramp Peak
While in ramp enemies spawn faster and faster until it reaches a peak where it spawns in a horde then goes back to relax.

Dynamic Difficulty
The game has a dynamic difficulty, for this game I did not take a lot of input from the player instead only used our scoring as our sole input. To expand this would be easy, just more data to be read and translated into something reasonable. The more score you have the faster ramp state happens which means more peaks.
Environment Query System
A cool thing I discovered while making this was that of Environment Query system or EQS for short. It tooks some time but eventually I made it so the enemies used it. It projects points in various shapes from the origin. With these points you can add rules which determines the final score of the point. Afterwards its easy both see and pick which points are favorable versus not.
Here we can see our EQS system. For this one we have three rules which dictates the score.


These rules might seem simple but if we balance them right and put them together we can create something really cool! Different levels of difficulty can also easily be produced by simply picking a point other than the best. If we picked the worst all the time it would give us a "Dumb" AI and if we picked a weighted to the best we could create something more human like and not a perfect robot.
Follow the rules
The map consists of a short maze but it is very easy to find exits. L4D punishes players for separating but something like that would be hard with only one player. So what I made was to instead make a closed of map I created exits for the player. If you went out you would quickly see that it was not intended because the world is empty and uninteresting. If you still went out I activated punish mode, this mode put the player in constant ramp/peak without any enemy limit which is in place normally.
The good:
- My time schedule allowed me to complete all I wanted to do.
- Enemies spawn out of view.
- Enemies scale in difficulty depending on score.
- Enemies comes in waves(Relax, Ramp and Peak).
- Enemies spawn more and punishes the player if it does something which we do not want to.
- Enemies use the EQS system.
- Enemies de spawn if no longer necessary.
The struggle:
- Unreal makes a lot of things easy but if you are unfamiliar with how things work it easily becomes an obstacle instead.
- Communicating and trying to keep code optimized while using blueprints for the first time was a challenge.
- C++ and Blueprint integration took a while before I got used to it.
- Information online was a hit or miss, sometimes you got pretty decent documentation where you could tweak it a bit and then use while other times you came out pretty flat.
The unexpected:
- After the initial struggle with c++ and blueprint integration it went really smooth and was easy to change things.
- The things which went quick in the beginning thanks to using already existing support from Unreal became a big hassle when changing stuff was very time consuming and confusing at times.
- EQS was something which came in around the half way mark which I think i super interesting, I did find it a bit confusing how to use and it is something I would like to really understand or build myself in the future to really use it efficiently.
February 12, 2024
Started learning Unreal Engine and how to implement a simple AI and AIDirector.
March 04, 2024
The last Individual course just ended, started working full time on specialization.
March 4, 2024
Got a simple AI a basic AIDirector shell to work together
March 11, 2024
AIDirector now has some basic features implemented. Had to figure out event dispatcher to make it work.
March 13, 2024
Discovered EQS which fits well with what I'm trying to do.
March 18, 2024
Back to AIDirector after some work on EQS but now spawning happens outside view.
March 26, 2024
The game now cycles between Relax, Ramp and Peak. This is similar to a horde ramping up towards a big showdown(peak) where the player has to defeat a final wave to then begin the relax phase where nothing happens until ramp begins again.
March 29, 2024
If the player doesn't stay within bounds I punish the player


My specialization is intended to work as a small version of what L4D had.
- Create a simple AI which uses some sort of perception system.
- Make AI chase player if seen.
- Have an AI Director who handles the enemies.
- Spawn in AI depending on what the player does.
- Spawn in AI outside player view.
- Scalable difficulty depending on player performance.
- Spawning in a similar fashion to L4D where it has three different cycles
- Relax(Happens after a Peak where the player can relax without having to worry)
- Ramp(More and more enemies spawn accumulating to a Peak)
- Peak(This is where the player is swarmed and has to battle it out to survive)
- Punish the player if it does something which isn't liked.

My first step was to research and begin to understand Unreal. This was everything from reading their own documentations, watching videos to reading stuff about it online.


Pawn sensing
Behaviour tree
First thing I did was to create an actor with simple blueprints which allowed it to chase the player. This was made with a behaviour tree. At first I used an older system called pawn sensing. This worked great to quickly make something which if in line of sight move towards someone. Pawn sensing was later on replaced by AIPerception system.


C++
Blueprint
My next step was to actually code c++ code in Unreal. My goal was always to create c++ code and exposing it to blueprint. For me creating c++ code feels more natural and gives more freedom but creating code which others can use freely and updating it when needed is something which I value highly. It took some time before I got the hang of it but it did not take long before enemies could be spawned around a location.


EQS visualized
EQS ruleset
EQS was discovered and implemented with three rules: distance, colliding and rotation. It took a while before I begun to understand how everything worked but I knew this was something extremely useful for what I wanted.


Relax Ramp
Ramp Peak
Similar to L4D I wanted to have a Relax/Ramp/Peak cycles happening where after a period of relaxation where no new enemies would spawn ramp would begin. In ramp they would start to spawn quicker and quicker until a peak was reached. When peak was reached a horde would spawn then the AI Director would go back to relax.

Playable area
The last thing I did was to punish the player if they went outside of the playing area. Normally when spawning enemies it would never go above the enemy limit but if the AI Director was in punish mode this law was bypassed. Relax state is there to give the player some rest after a huge battle but this is skipped while in punish mode.