New devlog! We just recently finished our first iteration of an
agressive animal. This AI is actually fairly simple, it only has one objective:
"Do not let any non-player characters enter the area". In other words, it's a Block that requires the player to build an
armory and
hunt down the animal in order to access the resources in the area it's protecting.
Now let's talk about the logic behind the AI. The behavior is controlled by States (
Patroling,
Running,
Scaring).
While in the
Patrol state the AI simply finds a random destination point inside a radius given through the inspector (we use OnDrawGizmos to see how big the area is). Once it arrives, it begins an idle animation which can be interrupted randomly and given a new destination point.
When a non-character enters the area, the Ai switches to the
Running state. While running, the animal gains extra speed and dashes towards the invader. Once it reaches the character the AI switches to the
Scaring state. The scared character runs away, canceling his current assigned task, while the animal AI switches back to the
Patroling state.
There is one exception to this logic. If the player brings a Hunting party to get rid of the animal, the AI will only switch to the
Running state if a character shoots and harms the animal. The player will have to bring a large enough party to bring it down.
Any kind of feedback will be appreciated!
Feel free to follow us on twitter and instagram: