I'm working on a sidescrolling dogfighting game and am looking to make it more exciting.
Right now the AI follows the following pattern:Step 1
Acquire a target. The AI weights the "score" of the target by comparing distance and health, so it's smart enough to go for weaker enemies that are further away (within reason).Step 2
Head towards the target, turning as necessary, until it's lined up for a strafing run. If it fails to align with the target within 2 seconds, it bails and moves to step 4.Step 3
Firing the guns for a couple of seconds, continuing to angle at the target.Step 4
Turn around and fly away for a couple of seconds, then back to step 1.
This actually works pretty damn well 1 on 1 against a human. The AI will come at me, shoot a few times, fly away and do it again. They're quite slippery to get in behind and take out.
The problem comes when AI is battling each other, especially when they're further away from the larger clump of other fighters. I'll often be flying across the field and see this:
They've acquired each other (due to the distance from other fighters), are attempting to line up the shot, give up, fly in the opposite directions for half a second then rinse and repeat.
I could add a check for the AI to never target something that's already targeting it, but that feels... incorrect (for lack of a better word).
Anyone done something similar? Any advice on how to prevent "dog chasing its tail" syndrome?