Here, I have a task of creating a complex and brand new AI units, which will are possible to use in a City environment. Since this engine could be used to create RPGs, many people will have this task. This I want this thread to be devoted to such questions and a solution.
First of all, I want to make a small overview to compare the AI systems of FPS and a city simulator. The last one is much different from the AI of Crysis or CryENGINE3 sample AI. In the regular FPS/Action games, you complete the levels and fight with AI units, which need to have functions of attacking, complex navigation, complex behavior. These can be called an NPC - the characters, who are playing against or with Player, and need to have the realistic behavior.
In the city simulator, player usually doesn't interact much with civilian AI. Here, the game needs to produce a lot of AI units around the player in its field of view. AI is spawning dynamically and is following the pre-made paths. Spawning such a great count of NPSc will hand the system down, and reduce the FPS count, therefore we should make it different. It shouldn't be smart or realistic, but it is needed just to fill the city environment. AI units should have the functions to follow paths, run or attack player if he attacks first, and sometimes say some phrases. They are similar to Boids, just more complicated. Such AI units can be called a Dummy - randomly spawned units, following paths and almost always ignoring the player.
Of course, in such games the regular AI for enemies or friendly NPCs is used too, but only in missions or in special moments.
Steps to create Dummy AI system
First of all, we need to find out, what elements of AI system should we create, to make it possible to use Dummy AI in maps. Imagine the city and the street. First of all, designer need to place the Paths on these streets - a special shapes, which are used to be followed by Dummies. Secondly, designer needs to define the Transition points - the special objects, placed between the end of one Path, and start of another. They are needed for random transition between these paths.
After the previous part of the task is realized, we need to spawn the Dummies on the Paths somehow. This is possible in 2 ways:
- We attach the Spawner elements to each Path, in a places where A Dummies should be spawned
- The AI system (Spawn System in further) will find the closest to the player paths and spawn the fixed amount of Dummies on them
First way requires a lot of designer work, but it allows designer more options to set up. Second way is more complicated to make, but it is easier to control, because all settings are stored in one place inside a code.
I think that it is better to use a second way. Let's talk more about it. It is possible to find the entities dynamically in game, so it will be possible to find the Paths, which are situated in a defined radius around the Player. After we find the list of these Paths, we should spawn Dummies on them. It is better to spawn Dummies all over the length of Path. In this case, we can make a path to be consisting of a few points, like on an image below:
Spawn System will take each Path from the list, then take each point from the chain, get its global coordinates, spawn the Dummy and make it follow the Path. Another system checks the paths areas for Dummies, and if they are too far from Player, it removes the redundant units.
Now, what we got from our plan
After all the steps above completed, we got the simple and useful system of civilian pedestrians, Dummies, which will be everywhere on the streets around the player. They will walk, switch the paths randomly. They will be removed from that area, and spawned in another place, when Player gets to another city area. It will create the impression on the Player, that the whole city is populated by those pedestrians.
This is an example of the system, in theory:
Now, I want to complete that system in scripts and programming. This article will be updated in future. I would like to listen to suggestions and discussions from other game designers and programmers about that task. Maybe together we can handle it and introduce the brand new AI System.