diff --git a/Assets/Scenes/Vasek.unity b/Assets/Scenes/Vasek.unity index 684a160..ef9c632 100644 --- a/Assets/Scenes/Vasek.unity +++ b/Assets/Scenes/Vasek.unity @@ -193,7 +193,6 @@ MonoBehaviour: - {fileID: 8768991388683709947, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} - {fileID: 6650340373999088090, guid: 76b3e3235b07ca04f91c9b020603e1dd, type: 3} - {fileID: 7834549091241900869, guid: 085af51cf1ada0a4fa8a290eba8b0fd5, type: 3} - - {fileID: 2628890434173161082, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} - {fileID: 8768991388683709947, guid: 1e3f34788e0cb3f49a0bef285d5b059a, type: 3} - {fileID: 1316835597118596560, guid: 685c607395b2cfa46a548c481d178540, type: 3} - {fileID: 1316835597118596560, guid: edd9e993fa2520f4095e33c7552ecd54, type: 3} @@ -203,7 +202,6 @@ MonoBehaviour: - {fileID: 5287741263160770601, guid: 7a596fa177a8fd34face58d8f58e0e41, type: 3} - {fileID: 2394897577413455488, guid: 1348a4eeda762ae4db83cd873efb4c44, type: 3} backgroundLevelBlocks: [] - bgParrent: {fileID: 1253020012} player: {fileID: 250075900} lastBlock: {fileID: 126480931} --- !u!1 &705507993 diff --git a/Assets/Scripts/BGRotation.cs b/Assets/Scripts/BGRotation.cs index 6ab3572..f0e5854 100644 --- a/Assets/Scripts/BGRotation.cs +++ b/Assets/Scripts/BGRotation.cs @@ -5,10 +5,12 @@ using UnityEngine; public class BGRotation : MonoBehaviour { private Vector3 rotation; + private ProceduralGeneration bgParrentScript; private void Start() { rotation = new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)) * 0.009f; + bgParrentScript = GameObject.Find("Level").GetComponent(); } void FixedUpdate() @@ -20,7 +22,9 @@ public class BGRotation : MonoBehaviour { if (other.tag == "platform") { + this.bgParrentScript.backgroundLevelBlocks.Remove(this.gameObject); Destroy(this.gameObject); } + } } diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs index 5adf886..78cac6c 100644 --- a/Assets/Scripts/ProceduralGeneration.cs +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -15,7 +15,7 @@ public class ProceduralGeneration : MonoBehaviour public List backgroundBlocks = new List(); public List backgroundLevelBlocks = new List(); private float maximumDistanceOfPlatformFromPlayerBg = 600.0f; - public GameObject bgParrent = null; + private GameObject bgParrent = null; public GameObject player = null; public GameObject lastBlock; @@ -103,13 +103,16 @@ public class ProceduralGeneration : MonoBehaviour levelParrent = this.gameObject; lastBlockPrefab = this.gameObject.transform.GetChild(0).gameObject; lastBlock = this.gameObject.transform.GetChild(0).gameObject; + if (bgParrent == null) + { + bgParrent = GameObject.Find("Background"); + } this.spawnedLevelBlocks.Add(lastBlock); } // Update is called once per frame void Update() { - // if (playerControlsSript.isFalling) // { // return; @@ -159,7 +162,10 @@ public class ProceduralGeneration : MonoBehaviour int blockToSpawn = Random.Range(0, (levelBlocks.Count + 1)); - if (levelBlocks[blockToSpawn].name == lastBlockPrefab.name) + if ( + (blockToSpawn > -1 && (blockToSpawn < levelBlocks.Count)) && + (levelBlocks[blockToSpawn].name == lastBlockPrefab.name) + ) { Debug.Log("Same Block"); if (blockToSpawn > levelBlocks.Count || blockToSpawn < 0)