From 7ef3e2cd866f38dd4e43d3bb79ba4ee2d10cf905 Mon Sep 17 00:00:00 2001 From: GamerClassN7 Date: Sat, 29 Jan 2022 19:37:40 +0100 Subject: [PATCH] Procedural Generation Tweaks --- Assets/Prefabs/Player.prefab | 2 +- Assets/Scenes/Vasek.unity | 14 +++----------- Assets/Scripts/ProceduralGeneration.cs | 14 ++++---------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index cbf4a12..9c7c2c4 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -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: diff --git a/Assets/Scenes/Vasek.unity b/Assets/Scenes/Vasek.unity index bd9f8ca..1518463 100644 --- a/Assets/Scenes/Vasek.unity +++ b/Assets/Scenes/Vasek.unity @@ -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 diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs index e246395..e97417e 100644 --- a/Assets/Scripts/ProceduralGeneration.cs +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -7,10 +7,8 @@ public class ProceduralGeneration : MonoBehaviour public List levelBlocks = new List(); public List spawnedLevelBlocks = new List(); 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; } }