Sorry if I don't write this properly, this is my first post here. I am working in Unity 2018.2.xx I have an issue where the current solution for checking whether a squad formation is broken. For ease of explanation, it's easier to visualise in 2D space from a top-down perspective. currently, there is the Squad is tracked by its own class and is an empty game object. the units in the squad have their own unit class and pass data to the Squad controller when needed. i.e on the death of a unit, it tells the squad manager to remove itself from the squad
the Squad formation is tracked in a 2D array and for testing purposes, the squad was formed in a 3*3 square as I tried to display below
o o o o o o o o o
what I need, is a way to detect when the squad is split into two, by the player killing/ removing units from the middle. i.e the squad on the left still has one unit in the middle, and when the unit in the middle column, the unit "breaks" and the remaining survivors scatter.
o o o o x o o x o o x o o x o o x o
Currently, I am checking each column and making sure it isn't the start or end. Then, checking the row to see if there are still units in that column. if not, it runs the splitting functions.
so my question is, is there a better way to do this without going too complex with the approach