Working with AI
In our previous dev log, I mentioned that we undertook an attempt to rewrite the AI system for our game. We decided to use a simplified version of the GOAP system. At first, we wanted to write a framework from scratch, but in the Unity Asset Store, we found a tool called SGOAP, which turned out to meet all our needs.
However, SGOAP is only a high-level tool, and we had to prepare all operations related to AI behavior (player detection, shooting, etc.) ourselves. Although in this case, we also decided to simplify implementation process. Instead of writing from scratch the logic responsible for the movement of agents in 3D space, we decided to rewrite a litle bit the Invector controller, which we used in the initial phase of the project. The combination of SGOAP and Invector resulted in a quite competent tool.
The animations seen in all the videos are temporary. Once we have all the AI details ready, we will buy some fancy animations from one of the asset stores (Unity, Unreal, Cg trader, etc.).
Types of AI
At this point, we have managed to prepare several types of AI. Below is a short list, along with short videos showing AI in action.
Shotgun and Assault Rifle.
// The opponent with a shotgun will be equipped with more aggressive behavior, which means that most of the time he will try to get as close to the player as possible. Its attack range has been set between 5 and 25 meters, which means it can also attack the player from a greater distance if necessary. In addition, the agent moves in a mode that we refer to as ScootAndShoot. This means that after a shot is fired, the agent will try to find a new position for attack. This position will be calculated, among other things, based on the minimum/maximum range of movement expressed in degrees defining circular movement.
// An opponent equipped with an automatic rifle will also move in ScootAndShoot mode. However, unlike the opponent with a shotgun, he will be equipped with more cautious behavior. He will have an increased attack range - a minimum of 15 meters and a maximum of 45 meters. In addition, the opponent with an automatic rifle will be equipped with grenades. When deciding to attack, the agent has been assigned a 50% probability of throwing a fragmentation grenade. It is worth noting here that the throwing force and distance are calculated by an algorithm. This means that the agent does not throw the grenade mindlessly in front of him:
// Here is an additional example, showing the behavior of agents in a larger group:
An opponent with axes
// The behavior of the opponent with axes will be similar to the behavior of the opponents from Serious Sam 4. Their main task will be to overwhelm the player, using a large number of attacking agents at the same time.
// Groups of agents may receive support in the form of soldiers equipped with automatic rifles. Agents of this type will additionally be able to throw a smoke or fragmentation grenade. The probability of throwing will be increased compared to a basic agent equipped with an automatic rifle and will be set at 65%:
LMG soldier
// A soldier with a light machine gun will base his behavior on a simple cover system. After taking a defensive position, it will attack from an increased distance. In addition, the agent will change (at random time intervals) its position. When making decisions, it will take into account other agents using cover, as well as the cover available in the immediate environment.
What are the next steps?
In our next devlog I will show you a couple of wepaons that will be available in GAZ.
