OVERVIEW
This STEALTH GAME MONSTER AI is a blind, ethereal creature that locates prey with grasping tendrils and hearing.
This was my first attempt at programming AI in Unreal Engine, and it was produced for a school project. It took around 5 weeks, and I learned a lot along the way.
​
This AI was developed by me alone, expect for the graphics which were contributed by a programmer friend who tried his hand at Niagara.
​
FEATURES
BEHAVIOR TREE
Below is the behavior tree of the stalker. I tried to break down every behavior into smaller tasks for reusability. Every leaf and service in the tree is coded in C++.
​
The AI itself inherits from Pawn rather than Character, which means pretty much none of Unreal's out of the box functionality for AI were available to use. I coded basic tasks like "MoveTo", along with a custom a MovementComponent to make the AI move on the nav mesh. I read a lot of UE source code to understand better how to make things work. Using Pawn gave me more freedom to customize behaviors, for example I could make the AI move along a spline.
PATROLLING
The monster patrols along a path defined in the editor. The path is set with a spline, which allows for smooth turns and more realistic movement patterns compared to a waypoint system. Along the path search points can be set. When the AI hits a search point it enters a search state.
During the search state the AI shoots out tentacles from three different heights. Depending on the height the tentacles can be avoided by crouching or moving on an elevated surface for example.
The search is performed by line traces between the monster and the player. The length of the trace is interpolated between 0 and the max length.
CODE SAMPLES
STATES
AGGRESSIVE
If the monster is able locate the player character it will become aggressive. In this state it will chase down the player and attack it with melee attacks. The monster will remain aggressive as long as it can hear or feel the player.
The monster stays aggressive until it loses track of the player. It then performs a search at the last position where it heard the player make noise.
VIGILANT
If the monster hears a noise when patrolling it becomes vigilant. If the player keeps making noise the monster becomes aggressive.