This game was also featured on the Unreal student showcase fall 2020: Showcase
Levis Umbra is a stealth game where you must navigate an old mine operated by mining robots that may have gone haywire, you task is to navigate through the mine avoiding the robots and try to figure out why the robots are defective and hostile.
My main responsibility for this game was to create a hostile robot AI that would attack you on-sight. Without any previous knowledge on AI this was a difficult but doable task, luckily Unreal provides most of the necessary components
to make the AI come to life. This includes the core part of the AI; The perception system, this system allows AI in Unreal to get a baring of what is around them.
All the code was done in Blueprints because we were on short time and we did not want the designers or artists to compile and such.
The perception system of Unreal operates with the knowledge that every pawn has a perception stimuli source (you can turn off that every pawn acts like a source and add it manually) that acts as the “tag" for the AI to know what causes a sight, sound or touch event.
A quick note on what is happening in the video: as shown the AI has circle around them this indicates each sense that an AI can perceive (noted in the top left), my AI uses sight and hearing where if the player walks into the sight
radius a red orb will be shown indicating the last/current position the AI has perceived something.
Each AI also has a direct line-of-sight cone that has a certain range where if the player enters that cone, he/she will be immediately detected (in the video I made the cone very small for example sake).
This blueprint snippet is how Unreal gives back the sensed actors I use those sensed actors to determine next on what to do with them using the function Check Stimuli.
This snippet shows the Check Stimuli function that first checks on what to do with each actor and if they are part of the same team or the opposite team. I then break up the actual stimuli struct to get all the data I need to see what we are dealing with. At the end you can see a check for the “noise" tag this is how you can split of the different senses of the AI.
This snippet shows that at the end of the function it determines how it should handle the different senses, for noise it will call On Heard Noise and will handle it further while with sight it will see if the target is already in view if not we have now seen it and if the sense is lost it means we have lost the target.
For the AI's behavior I used the behavior tree system from Unreal I tried to keep everything that has to do with the AI's behavior in there and try to make it modular in a sense that you can swap out certain behaviors for others or add new ones.
The actual behavior tree for the medium AI (the AI shown in the videos and in-game) the AI has 5 different states depending on what is happening in-game by default it will go-to idle.
|Idle:||By default, the AI is in the idle state guarding its location, if it has a path the idle state will go to the patrolling state.|
|Alerted:||If the AI has spotted an enemy it will go into the alerted state, chasing the player and fire a flamethrower at him/her.|
|Spooked:||The AI goes to this state whenever it has heard a sound made by the player turning around to the location of the sound. If spooked again will go to the suspicious state.|
|Suspicious:||Whenever the AI heard a sound twice or the player is in the AI's sight for too long the AI becomes suspicious and starts investigation around the last seen location of the player.|
|Patrolling:||If the AI has a patrol path set and is not in one of the different top states it will just walk the patrol path, but it can still get into the other states along the path.|
In this snippet the behavior is shown how it handles the suspicious behavior, but it cannot reach the player's location, if so, the AI will just go around the player's location and look around.
This snippet shows that the behavior tree handles the detection of the player based on thresholds and sets the AI in different states based on what does threshold are set to.