This commit is contained in:
GamerClassN7
2022-01-30 11:43:14 +01:00
parent c8959959f0
commit 2bb3e99c35
2 changed files with 41 additions and 4 deletions

View File

@@ -9,27 +9,28 @@ public class ProceduralGeneration : MonoBehaviour
private int maximumNumberOfPlatformsAtScene = 100;
public List<GameObject> spawnedLevelBlocks = new List<GameObject>();
private float maximumDistanceOfPlatformFromPlayer = 20.0f;
private GameObject levelParrent = null;
[Header("Background")]
public List<GameObject> backgroundBlocks = new List<GameObject>();
public List<GameObject> backgroundLevelBlocks = new List<GameObject>();
private float maximumDistanceOfPlatformFromPlayerBg = 600.0f;
public GameObject bgParrent = null;
public GameObject player = null;
public GameObject lastBlock;
private GameObject lastBlockPrefab;
private GameObject levelParrent = null;
List<GameObject> spawnBackgroundObjects(Vector3 playerPosition, List<GameObject> backgroundBlocks, GameObject parentLevelObject)
{
List<GameObject> bgBlocksSpawnTemp = new List<GameObject>();
for (var i = 0; i < 200; i++)
{
int bgElement = Random.Range(0, backgroundBlocks.Count);
int bgElement = Random.Range(0, backgroundBlocks.Count - 1);
GameObject newBgObject = Instantiate(backgroundBlocks[bgElement], (Random.insideUnitSphere * Random.Range(300, maximumDistanceOfPlatformFromPlayerBg) + playerPosition + new Vector3(0, 0, 50)), (Quaternion.identity));
newBgObject.transform.Rotate(new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)));
newBgObject.transform.parent = parentLevelObject.transform;
newBgObject.transform.parent = bgParrent.transform;
bgBlocksSpawnTemp.Add(newBgObject);
}