![](https://static.wixstatic.com/media/11062b_6a134fc09ea34833a17d295e295ab517f000.jpg/v1/fill/w_1920,h_1080,al_c,q_90,enc_avif,quality_auto/11062b_6a134fc09ea34833a17d295e295ab517f000.jpg)
AI Demos
FPS Squad Demo
I wanted to take advantage of some of Unreal's most useful built in tools and systems that make AI more realistic or appear "smarter" to the player. The Environment Query system is a great example that fully realizes customization of AI in a dynamic way that can greatly enhances realistic behavior. This demo was a personal project for testing the capabilities and limitations of these systems how to best use them in a full game.
![](https://static.wixstatic.com/media/9234e2_31018a24506e4eaab9aceb2c8d90c8b5f000.jpg/v1/fill/w_807,h_454,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/9234e2_31018a24506e4eaab9aceb2c8d90c8b5f000.jpg)
I started working on a shooter project with the intent of creating a squad AI that navigates a dangerous level to an objective point, eliminating hostiles as it proceeds.
The commandos use squad AI and share blackboard information to handle enemy threats while the droid AI uses simplistic pursuit logic to overwhelm enemies.
I used this article as a great starting point for creating a more sophisticated shooter AI:
https://www.tomlooman.com/teambased-ai-in-unreal-engine-4/
Tom has some great work on his website and offers a lot of educational courses and material on Unreal and AI in general.
![squad.jpg](https://static.wixstatic.com/media/9234e2_556f7d18d9984ec7b9586f51c623c944~mv2.jpg/v1/crop/x_76,y_0,w_919,h_515/fill/w_457,h_256,al_c,q_80,usm_0.66_1.00_0.01,enc_avif,quality_auto/squad.jpg)
DESIGN
I started by making the commando AI pursue and end goal and letting the navigation mesh design the path to get there. This way the demo could simulate multiple varied pathways and I could later add obstacles and weights to paths that change the route they choose.
For pathfinding guide to UE4, I recommend this article which was very handy when I started using nav meshes in Unreal:
![ue4_navmesh.png](https://static.wixstatic.com/media/9234e2_b1681af4b9cb4d738f4230878b84131c~mv2.png/v1/crop/x_71,y_0,w_1171,h_654/fill/w_478,h_267,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/ue4_navmesh.png)
With an end goal in sight, the commandos march forward while engaging via the AI perception component built into Unreal.
While the AI perception kit works well in certain situations, my needs were a bit taxing to use as I have lots of AI.
Perception updates when an AI receives a change to their current perceptive state (i.e. they didn't see the player, and now they can). This caused the droid AI (red mannequins) to miss detecting commandos (white) quite frequently.
The droids can block their allies vision, which causes the perception component to also miss detection. To get around this, I used a collision sphere that signals to nearby enemies that their friend has entered combat
For taking cover, I used Unreal's EQS search system that generates points in the navmesh based on a grid. These points can be scored and filtered with vector math to constrain selection. Once a commando finds cover to hide behind, I had them peek their cover with raycasts before checking with their heads using offsets of their current position. This allowed for a dynamic cover system where anything that blocks visibility could be used for hiding behind and peeking over or around.
One of my design goals was creating squad AI that could traverse a level while displaying elite marksmanship and skill, while still feeling more human than robot.
The commandos follow a leader (the one with the icon over their head) and they do so by a fanning offset that keeps them dispersed but fluid.
They also retain formation while in combat by checking for a maximum distance from their commander. Since the commander drives the search for the goal, he would often get too far from his squadmates for them to catch up.
![ezgif.com-video-to-gif (2).gif](https://static.wixstatic.com/media/9234e2_1eadf024eef24709bd4e1b959052079d~mv2.gif/v1/crop/x_54,y_0,w_492,h_275/fill/w_457,h_255,al_c,usm_0.66_1.00_0.01,pstr/ezgif_com-video-to-gif%20(2)_gif.gif)
![raycast.jpg](https://static.wixstatic.com/media/9234e2_4d4351e13a0e402eaea60fc0f86cc4ef~mv2.jpg/v1/crop/x_38,y_0,w_835,h_468/fill/w_382,h_214,al_c,q_80,usm_0.66_1.00_0.01,enc_avif,quality_auto/raycast.jpg)
![ezgif.com-crop (1).gif](https://static.wixstatic.com/media/9234e2_079f0f19232e4cbc8a7c81027f977642~mv2.gif/v1/crop/x_0,y_2,w_469,h_263/fill/w_457,h_256,al_c,usm_0.66_1.00_0.01,pstr/ezgif_com-crop%20(1)_gif.gif)
Using a variety of Behavior Tree Tasks, Decorators, and Services I started simple and expanded from there. The dominant behavior while in combat is getting cover. If a commando has cover, they check to see if they can hit their target. If they succeed, they shoot at the target. If they fail, they try flanking or moving to different cover based on variables like visibility, distance to cover, distance to target, etc.
Melee is an extra behavior I added with a simple distance check while Retreating. If the commando is close to an enemy and wants to fall back to cover, they first check if a quick melee kill is an option.
Other behaviors like retain squad formation and bunching prevention help keep the AI "intelligent" while avoiding edge cases and infinite loops.
Overall this project was a passion project for learning and solidifying AI concepts in Unreal. The extra bits like sound and meshes are icing on the cake that made my demo environment more compelling. I plan to add a full un-edited video of the AI in action to give a better sense of the moment-to-moment experience.
Dark Shot VR
I worked on the AI systems and behaviors for Dark Shot VR. I helped make a pathing system as well as the general behaviors for some of the enemy types like the Drone, Ninja, and Tank.
![ezgif.com-crop.gif](https://static.wixstatic.com/media/9234e2_97ec5868d9784e6b81424a6d3aaaaa3b~mv2.gif/v1/crop/x_0,y_12,w_556,h_311/fill/w_468,h_262,al_c,usm_0.66_1.00_0.01,pstr/ezgif_com-crop_gif.gif)
![ezgif.com-video-to-gif (1).gif](https://static.wixstatic.com/media/9234e2_42f58848daaf4a3db61cc8b413484c28~mv2.gif/v1/crop/x_27,y_0,w_545,h_305/fill/w_429,h_240,al_c,usm_0.66_1.00_0.01,pstr/ezgif_com-video-to-gif%20(1)_gif.gif)
OBJECTIVE
We wanted to create AI that felt distinct and characterized by their color scheme and silhouette. This led to the decision to make different classes of AI that used distinct behaviors to attack the player.
The main enemy was a slow "zombie" archetype that walked directly toward the player to engage in combat. The other enemies needed a lot more logic to them in order to make them different and interesting. Drones came in 3 different kinds: Speed booster, Shielder, and Attacker.
Drones primarily want to help their allies, but without an ally, they try to explode on the player. This made them high priority targets that the player typically wants to attack first. The Attacker drones fire projectiles of energy at the player can can be dodged or shot out of the air.