diff --git a/Assets/Scenes/Vasek.unity b/Assets/Scenes/Vasek.unity index 31b7725..1bd5643 100644 --- a/Assets/Scenes/Vasek.unity +++ b/Assets/Scenes/Vasek.unity @@ -195,6 +195,11 @@ MonoBehaviour: - {fileID: 1316835597118596560, guid: edd9e993fa2520f4095e33c7552ecd54, type: 3} - {fileID: 1316835597118596560, guid: b140cd85c7d7ba64cbc9ab71d92e349e, type: 3} spawnedLevelBlocks: [] + backgroundBlocks: + - {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 @@ -291,6 +296,37 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1253020012 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1253020013} + m_Layer: 0 + m_Name: Background + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1253020013 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1253020012} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -3.7466898, y: 11.656877, z: 19.668505} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1287430439 PrefabInstance: m_ObjectHideFlags: 0 @@ -410,7 +446,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} propertyPath: m_RootOrder - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} propertyPath: m_LocalPosition.x diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs index ca1f8a5..408f5bc 100644 --- a/Assets/Scripts/ProceduralGeneration.cs +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -9,27 +9,28 @@ public class ProceduralGeneration : MonoBehaviour private int maximumNumberOfPlatformsAtScene = 100; public List spawnedLevelBlocks = new List(); private float maximumDistanceOfPlatformFromPlayer = 20.0f; + private GameObject levelParrent = null; [Header("Background")] public List backgroundBlocks = new List(); public List backgroundLevelBlocks = new List(); private float maximumDistanceOfPlatformFromPlayerBg = 600.0f; + public GameObject bgParrent = null; public GameObject player = null; public GameObject lastBlock; private GameObject lastBlockPrefab; - private GameObject levelParrent = null; List spawnBackgroundObjects(Vector3 playerPosition, List backgroundBlocks, GameObject parentLevelObject) { List bgBlocksSpawnTemp = new List(); 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); }