Building Shooter AI in Unreal Engine 4

You may have seen my earlier blog post about a 4-player coop game I’m working on inside of Unreal Engine 4. It had the first iteration on ranged combat AI and they proved to be a formidable enemy. The problem was they got stale pretty quick, with simplistic and predictable behaviors. The new AI improvements are a first step at addressing this issue.

AI combat stresstest in ue4

New AI Behaviors

Along with the concept of multiple teams, the bots now do some bookkeeping on their most threatening enemy (“aggro”) which is based on distance to an enemy (if within the boundary of ears/visions), the amount of damage taken from an enemy and if the other bot is seen or heard through weapon fire or footsteps. Meaning that whenever a bot is attacked by a (melee) bot that is running up close, a spike in aggro makes him the most threatening, telling the bot to pick him as the new target instead of the current enemy far away.

fighting ai in unreal engine 4

The next step is to start digging into EQS (Environment Query System) to improve both pathing and decision-making when picking a good destination to attack or defend a player or location. As of right now the bots pick a reachable position within a radius of the current enemy. Using EQS you can figure out if a node in the world has line of sight to the enemy or if it’s partial/full cover etc. giving the AI a better understanding of the environment and therefore making them a more interesting opponent.

Stresstesting AI

With all the recent changes to AI, and all the firepower that’s available it was time for a stress test to see how it performs and deals with large number of AI agents. An open map with 80+ bots carrying assault rifles, rocket launchers, explosive slug grenades and sniper rifles – the end result is a party. (please mind your sound level)


Since around Unreal Engine 4.6 you can record your gameplay and play it back from any angle, much like the Halo-series and Call of Duty: Black Ops. The only requirement is for your game to be networked (single player games would need to enable replication too for this to function)

I’ve starting to work on some spectator and playback functionality to review/debug AI behavior and to make footage capture a lot easier. This works too for playtest sessions, allowing me to review a playtest session and see how both players and bots performed! Below is the first result of a freezeframe flythrough of the AI stresstest session.

If you’re interesting in creating a third person game in C++ or to get started with AI, check out my open-source C++ Survival Game project over at GitHub!



    • Hi Kurt,

      Thanks! That does sound interesting! The current aggro system is pretty simple, but seems to hold up so far, we’ll see how well it holds up in the coming playtests.

      – Tom

    • Hi Mieszko!

      Yes they are using UE4’s BT. EQS is next on my list, unfortunately I noticed your site has been down for a while so I can’t get any of the resources.

      – Tom

      • All my blog posts have been converted to wikipages on, so the knowledge is not lost 😉
        However, I think there was no tutorial on EQS, though. But people use EQS a lot already, so there’s plenty of info on it online! I know we could use some decent documentation on EQS :/
        Also, since I’m currently using EQS myself now a bunch of cool EQS features is going to come out with UE4 4.11 😀

        • Ah that’s great news! I remember you had atleast one intro to EQS on your site at some point. Looking forward to those feature for 4.11 😉

          I’d love to know more about pathfinding with the available (navmesh & smartlink) systems, like letting the bot determine a better path from A to B based on certain desirability nodes. For example, a bot would avoid the fastest route if it knew that would make him walk through enemy line of fire. Much like Killzone’s AI (link in the References on the bottom of the post)

          – Tom

  1. Hi Tom

    Your work is inspiring
    I have been working on some AI quite similar to what you’re doing.
    Also Utilizing both BT and EQS.

    A small recording we did in a testplay with my team yesterday.

    It’s also an AI vs AI for an FPS/RTS Hybrid we’re building. The concept is about RTS commander assigning AI Squads to FPS players and fight in team battles. We’ve also implemented cover system and logic to support team leader.

  2. I can produce jump in level blueprint but i cant get fire action on mobile android.
    InputAction Fire get triggered but character not shooting at all.
    I just want to call startFire from blueprint.

    I setup in action input android_back btn works but not good solution .

    Maybe here i need some optimization.
    InputComponent->BindAction(“Fire”, IE_Pressed, this, &ASCharacter::OnStartFire);
    sorry on my bad en

Leave a Reply