Hey guys im currently working on a TD game and was wondering what would be the best way to go about making the tower AI. I was thinking having a sphere collider that would get targets as they entered the collider and assign them in an array, then check to see if the tower has a target if not it will select the closest enemy in the array and fire until out of range then rinse repeat.
I am new to AI so if this isnt the best way please help me out, also i was wondering what would b an effective way of handling the projectiles to ensure that they hit the target without it actually adjusting its course.
Thanks in advanced!
That is essentially exactly how a simple AI would deal with the problem, then only addition that you may want to consider is that you may wish to prevent 'overkill' That is if an entity is already targeted by enough towers to kill it during the cycle, you will want to choose a new target. If you don't do this, then you can have the condition where all the towers target the enemy at the front of the line only, and don't maximize the fire power efficiently.
If you are still looking for a solution, we have two awesome Tower Defense games complete with source code on ActiveDen.net - Buy Plugins & Code from CodeCanyon
Sorry for the spam, but figured this might help?