- Home /
How would the commander AI in an RTS game be realized?
After checking out some of the Unity concepts just recently, Unity seems to be all about constructing a game from small autonomous "game objects". This is a perfect match for shooters and other games where you essentially encounter individual enemies.
Now in a realtime strategy or tower defense game, for example, individual units have very simplistic behavior while there's a commander AI that controls them.
Where exactly would this commander AI be placed in Unity? Would I create a game object for that as well, driving all of the decision making logic from its Update() function or does Unity provide provide a special place for game controlling AI like this?
Answer by timsk · Sep 28, 2011 at 02:43 PM
I find, the problem with questions about AI, is that its all situational or personal preference.
I imagine, in most general TD games, there's the path-finding, creep picking and creep spawning. Then the towers AI (range,speed,creep detection etc). It makes sense for the towers AI to be attached to the tower, but the creeps AI to be attached to an empty gameobject.
Personally, the way I am doing it, is have a gameobject that is the "AIManager" that has the overall AI, then, i attach each enemies AI to the enemies gameobject.
That's just the way I see it, I'm sure other people would do it differently, and I'm sure at some point so will I.
In an attempt to directly answer your question... no, there isn't anything in unity that is designed specifically to hold AI functions.
Thanks. I agree, handling low-level behavior anywhere but in the game objects it applies to would be awkward. I was just wondering if there was some kind of game controller or conductor API that I could use or whether I would have to put it all in a game object (like your AI$$anonymous$$anager). Thanks for clearing it up!
Your answer
![](https://koobas.hobune.stream/wayback/20220612230054im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Enemies Moving Through Terrain Help 1 Answer
AI enemy scripting help 1 Answer
My Script keeps destroying all enemies instead of just one. 3 Answers
Shooting Damage Help 1 Answer