Procedural Generation Tweaks

This commit is contained in:
GamerClassN7 2022-01-29 19:37:40 +01:00
parent b021ea4e9a
commit 7ef3e2cd86
3 changed files with 8 additions and 22 deletions

View File

@ -1391,7 +1391,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3244356566819001084}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 4.32, z: 0}
m_LocalPosition: {x: 0, y: 4.32, z: 0.7}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:

View File

@ -427,17 +427,9 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3244356566819001073, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: 0.7
objectReference: {fileID: 0}
- target: {fileID: 3244356567786994344, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_Name
@ -453,11 +445,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalPosition.y
value: 3.18
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalPosition.z
value: -0.9
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3}
propertyPath: m_LocalRotation.w

View File

@ -7,10 +7,8 @@ public class ProceduralGeneration : MonoBehaviour
public List<GameObject> levelBlocks = new List<GameObject>();
public List<GameObject> spawnedLevelBlocks = new List<GameObject>();
public GameObject player = null;
private Vector3 lastBlockSpawnPoint;
public GameObject lastBlock;
private GameObject lastBlockPrefab;
private int blockIndex = 0;
private int spavnetobjectIndex = 0;
// Start is called before the first frame update
@ -18,7 +16,6 @@ public class ProceduralGeneration : MonoBehaviour
{
lastBlockPrefab = this.gameObject.transform.GetChild(0).gameObject;
lastBlock = this.gameObject.transform.GetChild(0).gameObject;
lastBlockSpawnPoint = this.gameObject.transform.GetChild(0).gameObject.transform.position;
this.spawnedLevelBlocks.Add(lastBlock);
}
@ -33,7 +30,7 @@ public class ProceduralGeneration : MonoBehaviour
int pieceCount = 10;
float radius = (pieceCount / 2) * 2;
float angle = 360f / (float)pieceCount;
Vector3 centerPoint = new Vector3(lastObject.transform.position.x, (lastObject.transform.position.y + radius), lastObject.transform.position.z);
Vector3 centerPoint = new Vector3(lastObject.transform.position.x, (lastObject.transform.position.y + radius), lastObject.transform.position.z + 2.0f);
float heightOffset = radius;
@ -52,14 +49,14 @@ public class ProceduralGeneration : MonoBehaviour
// Update is called once per frame
void Update()
{
int maxNumberOfBlock = 20;
int maxNumberOfBlock = 100;
Vector3 playerPosition = this.player.transform.position;
float distance = Vector3.Distance(this.spawnedLevelBlocks[0].transform.position, playerPosition);
Debug.Log("Index" + 0);
if (distance > 20.0f && this.spawnedLevelBlocks.Count > maxNumberOfBlock)
if (distance > 10.0f || this.spawnedLevelBlocks.Count >= maxNumberOfBlock + 5)
{
Destroy(this.spawnedLevelBlocks[0]);
this.spawnedLevelBlocks.Remove(this.spawnedLevelBlocks[0]);
@ -104,9 +101,8 @@ public class ProceduralGeneration : MonoBehaviour
if ((blockToSpawn > -1 && (blockToSpawn < (levelBlocks.Count - 1))))
{
blockObjToSpawn = levelBlocks[blockToSpawn];
instantiatedGameObject = Instantiate(blockObjToSpawn, new Vector3(0, 0, blockIndex * (b.size.z + 1.0f)), (Quaternion.identity));
instantiatedGameObject = Instantiate(blockObjToSpawn, new Vector3(lastBlock.transform.position.x, lastBlock.transform.position.y, lastBlock.transform.position.y + (b.size.z + 1.0f)), (Quaternion.identity));
this.spawnedLevelBlocks.Add(instantiatedGameObject);
blockIndex++;
}
else
{
@ -114,7 +110,6 @@ public class ProceduralGeneration : MonoBehaviour
foreach (var spavnedBlock in instantiatedGameObjectLists)
{
this.spawnedLevelBlocks.Add(spavnedBlock);
blockIndex++;
}
instantiatedGameObject = this.spawnedLevelBlocks[this.spawnedLevelBlocks.Count - 1];
blockObjToSpawn = levelBlocks[0];
@ -123,7 +118,6 @@ public class ProceduralGeneration : MonoBehaviour
Debug.Log("Spawn" + blockToSpawn);
lastBlock = instantiatedGameObject;
lastBlockSpawnPoint = instantiatedGameObject.transform.position;
lastBlockPrefab = blockObjToSpawn;
}
}