Going off of what little you provided, i'd say:
1.) As getyour411 mentioned, how are you setting up the squadrons?
If you are using lists/arrays: Each unit most likely has a management script on them, correct? So you can have a list of the squadrons they are in (or if only 1 allowed, a single variable). If that variable is null or 0 or some value you decide, then they aren't in a squad, if they are, then you probably have a game manager script that keeps track of all the squads and who is in them somewhere. Just make a cross-script call to the game manager and get a returned list of all the other objects in that squad.
If you are parenting all squads to a group (which would also make their squadron movement different than my answer below) then you would select all children under the parent node.
2.) This is a bit more difficult, that depends on what you define as "formation".. is it a box.. how big is the box? RxC size set? is that box dynamic in size. so if you have 4 units is it 2x2 and if you have 9 units it's 3x3.. or is it always a minimum of 5 units in a row and then start the next row? Or hell, is it a V shape formation?
When you move to a location, are you using something like a navmeshagent for AI.. or are you using graph nodes.. or are you doing it yourself because it's in "space"?
Chances are you want to go to a point.. so set all units to a point but depending on how your formation is, you may want to make their endpoint an offset of the main point so they don't all try to walk to the same point and collide.
3.) once you figure out #2, you'll be able to do #3 pretty easily.
↧