AI for Newell Escape Game
What you see here is the AI I made for the Newell Escape game. This map that the AI is moving on has 4 different sectors. Each Sector is set by 2 Unity GameObjects. When the AI spawns they get a random body type that determines how fast they walk and how aware they are of their surroundings. The AI is controlled by their GuardMode, which determines what they do. You got: Normal, Search and Chase. Normal they will just patrol the sectors, search that they will search the last location someone has seen the player, finally chase, when someone sees the player they chase him.
Here is the update for the AI, every frame it checks if it can see the player. Depending on their guardMode their behavior is chosen. Usually it’s normal so they walk from sector to sector. Here is everything what the AI does actively.
When the Guard’s mode gets changed it uses the Method “SetMode”. This will change the AI behavior according to the behavior set. Their speed gets changed. As you can see every behavior is different from each other, normal just changes the speed while search will try to lead the AI towards the last location of the player and Chase will alert every guard in the map of the player’s presence, which will activate search mode on all other guards.
Here you can see what happens when 1 guard sees the player. They all change their mode to search and try to look for the player where the other guard told them where he was.
The AI detects you with the use of a raycast and returns a value that effects the (seePlayer) Boolean. This gets done every frame, The FOV is different for each bodytype, aggressive AI gets a higher FOV (Field of View) while the normal gets lower FOV.
Here is the CentralIntelligence Script. It sets the sector locations based on the sector location South East and Sector Location North West. Every guard makes use of this script and every guard is connected to it by the use of a list of the GuardAI script. They get their destination based on a number in between the current sector’s Sector Location SE and NW. When a guard sees the player he will alert all the guards in the area of your presence and will share your location with all of them.
Movement Script for Newell Escape Game
What you see here is a Capsule with a top view camera placed on it. I’ve made this movement script for the game me and a couple of others are working on. We’re close in the development stage but making a movement script in 3d requires knowledge about Vector3’s. It doesn’t look like much but I learned a lot of Vector math from making this script.