Trying to create a simple AI.

So, I know there’s thousands of examples, but I’m trying to do something a little different.

I have multiple units running around, that will, in-face collide with eachother. Now, what I want them to do is line up side by side basically, basically a “Formation” as a RTS game would call it.

The reasion is, I don’t want them to all just run to one spot and kick the other one forward, then I would have a constant domino effect.

========

Also, is there a way to draw a raycast from one object to another, to make sure it’s “Visible” aswell as “In range” before I tell it to start attacking, that Way i won’t have my AI chasing down someone in the fog of war.

To draw the ray cast, just use Debug.DrawLine with the start position where the ray starts and the end position where the ray collides (or the maximal distance if no collision). The visibility or the range is basically the hit distance.

To create a formation for your AI agents, there are many ways to do that you want and no magical one. You can use static offsets, steering behaviours… I suggest you do some basic searchs on the internet because this is not relative to Unity 3D Technology. You can try http://aigamedev.com for instance.