I guess I didn't explain my problem very well. Sorry. I didn't even realize it was a thing until I noticed that my level structures seemed very non-random. I generate 30 different objects inside a script in the start function. They are a random object from 3 choices, which seems to work well or at least I don't notice a repeating pattern. It also gives them a semi random position offset from the position parent object, also seems to work fine.
The issue is that the pattern that appears on the screen when the level is loaded is the same every time the level is loaded. It was quite random the first time, but upon subsequent attempts at the same level, the objects are in the same pattern. Basically the function loops and asks if a position has an object or not, if it doesn't it tries to make one. Or rather, if it hasn't attempted to make one.
Relvlent code:
private int RNG()
{
return Random.Range(1, 100);
}
void SpawnUntilFull()
{
Transform freePosition = NextFreePosition();
if (freePosition)
{
MoveRandomly();
RandomAngleGen();
if (RNG() <= chance30hp)
{
chosenGameObject = asteroid30hp;
}
else if (RNG() <= chance20hp)
{
chosenGameObject = asteroid20hp;
}
else if (RNG() <= chance10hp)
{
chosenGameObject = asteroid10hp;
}
if (RNG() <= spawnChance)
{
GameObject destructible = Instantiate(chosenGameObject, (freePosition.position + moved), Quaternion.Euler(0, 0, angle)) as GameObject;
destructible.transform.parent = freePosition;
}
}
if (NextFreePosition())
{
Invoke("SpawnUntilFull", spawnDelay);
}
}
Transform NextFreePosition()
{
foreach (Transform childPositionGameObject in transform)
{
if ((childPositionGameObject.childCount == 0) & (!childPositionGameObject.CompareTag("Attempted")))
{
childPositionGameObject.tag = "Attempted";
return childPositionGameObject;
}
}
return null;
}