Alright! I have a question and I hope the greater minds of this forum can point me in the right direction!
Currently I have squads that are formed as follows;
Squads consist of 5 - 20 troops
A “Formation” gameobject is spawned on the squad leader.
The formation gameobject consists of empty gameobjects spaced out into a design
(A “Line” Formation has empty objects in the shape of a line while a “V” formation has the objects shaped into a V and so on)
Each member of the squad is assigned an empty gameobject as its nav destination and the formation follows the squadleader.
First Question!: is there a more efficient way of doing this?
Second Question!: Depends on the answer to the first question! I plan on having as many soldiers as I can and have them grouped into “chains of command”. I want them to use a little processing power as possible and units will get smarter when the player is closer to them.
Is there a way to have a unit of 50 men be controlled by a single navmesh agent successfully when viewed far away to conserve processing power?
I plan on switching them to individual agents as the player gets closer so they can then take cover and act individually.
I haven’t tried making an RTS with Unity’s NavMesh system (or any RTS, really), but I’ve heard rumors that it’s not the best fit.
I’ve watched this tutorial before, and it looks pretty solid. It also uses the free version (I belive) of the A* project, which has a very good reputation (I haven’t used it myself, sadly). While it doesn’t answer your questions, I’d give it a watch. It’s kinda old (it references the free/pro split), but the advice is otherwise still good. To put it this way - these days you don’t use A* over Unity pathfinding because it’s free, you use it because it’s better.
For question A: It seems like a good idea. The question is how you want your agents to behave if they’re in each other’s way. Do you want the Starcraft 1 behaviour, where units block each other? (Probably not). Do you want the Starcraft 2 behaviour, where friendly units “push” each other slightly? Or do you want something like Age Of Empires 2/3 / Dawn Of War where units in the same selection/squad can move through each other like they’re ghosts?
Both the SC1 and SC2 behaviours will prevent units from standing in exactly their squad positions. The AOE2 method allows for perfectly aligned squads, but units will have to clip through each other to get there (not really a big problem). If you want to do a hyper-realistic simulation where units go to their designated positions exactly, without ever clipping through each other, that’ll be really hard.
For question B: This seems like a neat trick. Don’t do it unless you A) know that your pathfinding stuff is slowing down the game and B) are certain that this optimization will be worthwhile. Don’t optimize before you need to! Use the profiler to figure out what’s slow!
You are right about optimizing. My AI system can currently handle around 60 troops in combat when they are using their full “Brains” I would like to reach levels in the hundreds or maybe even thousands if possible by prioritizing their intelligence based on how close they are to the player because I am making a FPS.
I think the majority of the slowdown comes from the raycasts caused by the cover system, but I want to make sure that I am optimized on every aspect.
I am inspired by the Total War Game that just came out. I am thinking of implementing movement similar to it when squads are far away, and maybe even assigning damage to squads in a more abstract manner in the distance, while up close it plays like a FPS where every bullet and explosion counts.