Hello I seem to be having some great deal of trouble making a box formation in game. here is a code snippet of what I'am doing I just need help with logic to get it in a box formation.. Been working on this for the past 2 days and I cannot seem to get them in a box.. only Echelon Left. Code (csharp): void CreateFormation() { //Anchor the first position SquadPositions[0] = Center.transform.position; //Increment the currRow for (int j = 1; j < SquadPositions.Length; j++) { //Next Row SquadPositions[j] = new Vector3(SquadPositions[0].x, 100, SquadPositions[0].z + (j * flockSeperation)); for (int k = 0; k < columns; k++) { SquadPositions[j] = new Vector3(SquadPositions[j - 1].x + (k * flockSeperation) , 100, SquadPositions[0].z + (j * flockSeperation)); } RaycastHit hit; if (Physics.Raycast(SquadPositions[j], -Vector3.up, out hit)) { //Set the height of the squad position SquadPositions[j] = new Vector3(hit.point.x, hit.point.y, hit.point.z); } } }
I know it's to late. Can you share me this algorithm? I am needing arrange object in a box formation like you ( thanks!
Hey this was EONS ago but I think I can come up with something by the end of the week for you, I have a few algorithms laying around and what are you trying to-do this for? Unity's Built-in Nav Mesh system or custom positioning system?
Though I think for this exact script I don't have access to any longer with old company... Let me know what you need done and I can help you out.
Thanks for your reply. I found a algorithm to make a crowd to be square formation. But can't find any algorithm to make crowd fill a circle formation (not a ring). Do you have any idea?