An AI is a very broad topic, but I would like to know specifically how AI in games do not tear the framerate a new hole to breath through.
In my AI I usually use Vector3.Distance to tell the AI when to attack and what not when it is within a specifically range. But measuring distance on several AIs are very recourse expensive and tears the frame rate to pieces. But in games like Halo, Battlefield, COD there are sometimes 20 plus enemy AIs and plus friendly ones, but how do they manage to have a steady and solid framerate with that many AIs?
But just creating a game in general is such a huge -blaming- challenge. But I find AI very difficultly. I know there are several topics on how to optimize the framerate, but I am more about creating a AI with low loss of framerate using different techniques.
What are some no-no´s when scripting an AI? In order for them to be “clever” a lot of code is required. Therefor more code = less framerate.
I guess Vector3.Distance is a no-go. An alternative is triggers? or other?
But what about Instantiate? The AI Instantiates bullets(In Halo needles, plasma bullets that the player can actually see and get hit by).
Raycasting? What determines whether the player gets hit by a bullet fired from the enemy AI? Raycasting is expansive when used in large numbers.
I am sorry of this is to much, but I am on very deep water here. My technique for creating an AI is usually expensive and using one or more of the things above and I would like to hear an alternative to those three tings above. Some less expensive for creating several AIs. And if I left any out please tell me.
Thank you so much.