How would I create a non-uniform random generation of gameObjects (enemies) that mimic the formation of a horde like this image:
I want there to be more gameObjects in the front and less as it trails off towards the back. I thought of making an Empty gameObject and having the enemies target with code like this:
public Vector3 target : Transform;
if (target == null && GameObject.FindWithTag("Empty"))
{
target = GameObject.FindWithTag("Empty").transform;
}
But that won’t give me the “trail” effect. The code for my randomly generated enemies is :
void SpawnHorde()
{
for (int i = 0; i < hordeCount; i++)
{
Vector3 spawnPosition = new Vector3(Random.Range (0, 200), 50, Random.Range (0, 200));
GameObject obj = Instantiate(Resources.Load ("Prefabs/Sphere"), spawnPosition, Quaternion.identity) as GameObject;
}
}
Right now they are cubes but later will be replaced with a different prefab.
If anyone has any suggestions, they would be greatly appreciated! I am stumped right now