Getting started on AI
Before getting started on my AI, I spent time researching AI behavior in Metal Gear Solid. I have personally played every metal gear solid game but it was worth while refreshing my memory.
Enemies have set patrol paths with a rotation to look in a direction once certain points have been reached. They generally have a short vision cone which will cause them to react to the player once the area has been breached. They also react to noise such as footsteps on certain surfaces and the player knocking on walls.
When the player is spotted the enemy go into "Alert phase" and will pursue the player while attacking until line of sight is broken. When the line of sight is broken, the enemy enters the "Caution phase" and will search the area for a short time, before resuming their patrols if the player is not found.
Metal gear solid 2 advanced this further by having extra enemies enter the area and search points of interest, such as corners of rooms during "caution" and even clearing the last room the player entered.
Caution phase searching
Room clearing
For this project I will be steering closer to the AI behavior in metal gear solid 2, as the unreal engine is more than capable of handling these more advanced tasks.
To begin this process, I set up an AI character, Controller, behavior tree and blackboard to get started. I then worked on a patrol task, which I can customize for each individual AI when I place them in the level.
Patrol
To create the patrol task I created an actor to use as a Waypoint. Since it is an actor, I can place it anywhere in the Gameworld and get its location, so when I then create a variable of the Waypoint in my AI character blueprint, Expose it, and set it as one of actors placed in the world using "pick actor from scene". I then created events in the "Patrol task" blueprint to move the player to selected Waypoints in a sequence, which can be reversed once the end of the patrol is reached.
Move to waypoint
Patrol sequence
The patrol sequence uses a Enum variable which is increased or decreased after each patrol is called, depending on if the route is reversed or not.
Patrol video