Procedural Generation

This commit is contained in:
GamerClassN7
2022-01-29 14:39:34 +01:00
parent 281f111a6c
commit ce69db1383
3 changed files with 88 additions and 27 deletions

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ProceduralGeneration : MonoBehaviour
{
public List<GameObject> levelBlocks = new List<GameObject>();
public Vector3 lastBlockSpawnPoint;
public GameObject lastBlock;
// Start is called before the first frame update
void Start()
{
for (var i = 0; i < 10; i++)
{
MeshFilter meshfilter = lastBlock.GetComponent<MeshFilter>();
Bounds bounds = meshfilter.mesh.bounds;
float scale = meshfilter.transform.localScale.x;
Bounds b = new Bounds(bounds.center * scale, bounds.size * scale);
Debug.Log(b.size.x);
GameObject instantiatedGameObject = Instantiate(levelBlocks[1], new Vector3(0, 0, i * (b.size.z * 2)), Quaternion.identity);
instantiatedGameObject.transform.SetParent(this.gameObject.transform);
lastBlock = instantiatedGameObject;
lastBlockSpawnPoint = instantiatedGameObject.transform.position;
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b968982a4fb5e5e469b75c7d5c4abb25
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: