Best ways to create awareness of an AI in battle

Hey guys,
I’m working on an Android flight combat game ‘Project Salvation’. It will mostly have the player, in a vehicle, and other AI vehicles, proceed through varied environments to shoot down drones.

I used to play the Call of Duty series, and I always wondered how our friendly AI would always know when the current encounter location was cleared of enemies and then, they would automatically proceed to the next waypoint. And the fact that only some of the AI would proceed to kill the enemy, while the others would wait made me think that there might be some kind of manager running in the background allowing the AI to choose which targets to engage. So my question is this
-Since my levels are mostly linear, should I keep it simple and tell the AI to keep moving straight with me, and engage anyone who gets too close? Or
-create a battle manager at specified encounter points, which maintains a list of bad guys and good guys, and assign targets randomly to friendly and enemy AI so it looks random and realistic?
-any other way?

Which would be the best and convenient method to implement?

Thanks!

1 Like

Good question! Consider implementing your AI iteratively. For the first pass, just use a steering behavior (follow, or flocking perhaps) to keep friendly AI near the player. When an enemy gets close, change to a pursuit steering behavior, firing when the enemy is in sights. If the enemy is killed or the friendly loses it, return to the initial steering behavior.

Keep your code as decoupled as possible; try to implement it so you can easily swap out the AI code with more advanced code in the future without breaking other, non-AI code.

Then implement the rest of your gameplay.

You may find that this simple behavior is entirely sufficient. Or, even if the AI isn’t exactly what you want, you may find that you need to prioritize your effort elsewhere to address more serious issues before revisiting AI. If you do end up revisiting AI, you’ll probably have a lot more insight into what you need, given that you’ll have been playtesting the game for a while. And if you keep it modular, you can fairly easily swap your AI code out with different code without breaking anything else.

3 Likes

Thanks @TonyLi for the reply.

I will implement the first pass using UnitySteer. I will be using a combination of follow and separation behaviours, not to mention obstacle detection, to keep the friendlies near me.

I have already created some bits of AI for attack, pursue using behavior trees(Rain AI). For attack, the AI will move slowly towards the median of the nearest 3 enemies, while it’s weapons, selected randomly, will do the job(pew pew pew!(Sorry, it’s sci fi :p)) What remains is the implementation of a system to swap these behavior trees at runtime depending on the objectives.

So you say this is interesting enough for the player. Just have to make sure the friendlies aren’t as accurate as us, right? Or else, they’ll kill everything and the game would have finished even before it starts.

It’s a start at least. Game development is an iterative process. Start simple and add complexity only where it’s needed. I agree that it’s a good idea to make friendlies not as accurate as players.

2 Likes

Your 2nd option is probably better. Since you know how many enemies you’re spawning, the AI could keep track of how many enemies you should kill before moving onto the next objective.