Now that I have some obstacles to work with; time to start getting the AI and terrain elements into the concept. I have put aside any additional optimization for later, when the major bottlenecks become more obvious.
At the moment it looks like a decent game can be put together with the Dark AI plugin judging by how the obstacles look; but I wanted to add a feature to assign the AI to certain layers on the terrain. To do so I have added an option to generate AI containers to each layer; or if required a specified list of containers are given their own copy of the obstacles in each layer.
To stop the AI from moving from one layer to another I made an optional parameter which forces the generator to create obstacles surrounding the given area, so that the following unsealed layer
ends up looking like this.
Now any AI assigned to the hills, represented here by the grey bits, stay on the hills. There are an excessive amount of obstacles here, but I got an idea of what I will do to simplify the result; something I will look into another day.
Now I will start working in 3D. I will use the tradition of using cones as Dark AI entities. I assigned green AI to the green layer, blue AI to the blue and red AI to the red layers. The player is the yellow sphere.
So far as shown below, the generator has a margin parameter which causes the Dark AI obstacles to overlap a bit to make sure no issues of getting stuck can happen.
I am considering adding some filtering later on to make beveled corners so that the AI walk around areas in a bend rather than making constant 90 degree turns around corners. Or perhaps if Lee decides to use this concept, he will have a better idea.
To illustrate what is happening for my own understanding, I have added a plane rotated about the X axis by 270 degrees; and I have textured it with the heightmap.
Next I added the second layer which is situated in the hills. I used the AI Debug Show Obstacle Bounds command to reveal the edges of the obstacles; which is one of the many Dark AI debugging features.
Here is the latest obstacle chart illustrating what I will be working with for the time being.
The colours are faded together a bit much but the image illustrates how the AI entities will stick to areas that do not feature their colour; for example, the red guys will stick to the green-blue spots, and the blue guys will stick to the red-green spots; again the hues are not very saturated, but when the terrain is generated the illustration should look a lot more clearer.
The reason why the AI will stick to the areas illustrating their opposite colour is because the obstacles of their own colour are blocking their movement; each obstacle is illustrated with semi-transparent boxes mixing blended with the other boxes, hence the colour alteration.
Now below is an illustration containing the red obstacles, and the red guys surrounded by them. The white bits underneath the AI cones represent the mountains for what is to become the terrain.
The blue guys are not concerned about red obstacles, they belong to a different AI container; AI containers separate AI elements. However, the blue guys will never climb up hill into the white spots; the following image indicates why.
All of the white bits in the above image contain blue obstacles. If we wanted the blue guys to climb up the mountains we would need to transfer them into the container assigned to the top layer.
Now; I forgot something when working on the terrain. By default the Blitz Terrain plugin will not mirror the heightmap image when sampling. This is an issue because high coordinates in 2D imaging are at the bottom of the image, but in 3D the low coordinates are at the bottom.
Using the following heightmap, I expected to see hills in the north-east end of the object, but they ended up in the south-east.
To fix this problem, the following line forces the Blitz Terrain system to mirror the heightmaps it samples.
BT SetAtMode 1
Hopefully if Lee uses this concept, he is also mirror imaging his Blitz Terrain heightmaps otherwise something will need to change here.
Now that the hills are in the right place, the green guys are at the bottom, the blue guys are in the middle and the red guys are high up in the hills, I can add the terrain. I will integrate the terrain builder with my AI terrain class for convenience.
So, as hoped for; the green guys follow me along the gullys and valleys.
The blue guys are sticking at mid altitude.
The red guys are on the mountains but do not concern themselves with my yellow player because we are in different containers. Neither do the green guys concern themselves with me.
What is left to perform now are real time terrain changes; something I will need to do with the free version of Blitz Terrain some how... I will also create special ramp like elements which allow the AI to walk up or down layers. I will also add an array of user defined obstacles for each layer to work with the buildings set by the FPSCR editor in conjunction with what is discussed
here in the blog.