Closest target AI example
Posted: Sun Feb 26, 2017 3:47 pm
Hello!
I made a small demo of AI that targets the closest enemy and only if no other AI is already closer to that enemy.
The demo is pretty quickly made and thus the programming is kind of messy and not a good example of programming, but the logic of the system is the main thing here.
Basically what the code does is:
I made a small demo of AI that targets the closest enemy and only if no other AI is already closer to that enemy.
The demo is pretty quickly made and thus the programming is kind of messy and not a good example of programming, but the logic of the system is the main thing here.
Basically what the code does is:
- Loop through every target actor clone
- Find the AI that is closest to the current target
- See, if the current target is closer to the AI than the previously found closest target and if it is, replace the old with the current one
- Move each AI to the target that is closest to them