During the last few weeks we have been advancing in the development of the game and we have been focusing in the development of different AI for the monsters of Lamentum.
Mainly, the AI of the enemies is programmed like a state machine that it could split in three:
– Normal State
– Alert State
– Combat State
In the Normal State, the AI will have a patrol route defined by the map where it will be. When the state changes to Alert State, the AI will have located to the player and, depends of the type of monster, it will seek to reach to the next state, the Combat one.
Both to patrol and to reach to the player previously located, the AI must be able to find a valid path to reach to his goal.
To get this, we have developed a pathfinding based on the testing of colisions.
To do these checks of colisions, must be defined a volume for each AI, we like very much this, due to our monsters have varied sizes (since little monsters to humanoids and others big and fierce ones xD).
According to this volume and to avoid that the monster was trapped somewhere without knows how escape and goes out, we draw two triangles of 45 degrees in base to this pivot, pointing to the possible directions of movement, after the result, we do the testing of the colisions in base to these triangles.
The reason to use two triangles instead of only one is simple, the corners, each triangle informs us of the possible colisions that can have in its zone.
We like the result and we believe it’s right for the monsters of the game, which we don’t want that always search the best possible path, but that they will be able to avoid obstacles.
In the beginning we considered programming an algorithm A* search to the pathfinding, but according to the different possible volumes of the monsters and the fact that our stages aren’t completely based on tiles, we discarded it.