From ce69db1383169881562dfcdf60e21b942fb5ff2e Mon Sep 17 00:00:00 2001 From: GamerClassN7 Date: Sat, 29 Jan 2022 14:39:34 +0100 Subject: [PATCH] Procedural Generation --- Assets/Scenes/Vasek.unity | 65 ++++++++++++--------- Assets/Scripts/ProceduralGeneration.cs | 39 +++++++++++++ Assets/Scripts/ProceduralGeneration.cs.meta | 11 ++++ 3 files changed, 88 insertions(+), 27 deletions(-) create mode 100644 Assets/Scripts/ProceduralGeneration.cs create mode 100644 Assets/Scripts/ProceduralGeneration.cs.meta diff --git a/Assets/Scenes/Vasek.unity b/Assets/Scenes/Vasek.unity index 4bb6390..ba52f84 100644 --- a/Assets/Scenes/Vasek.unity +++ b/Assets/Scenes/Vasek.unity @@ -1878,11 +1878,22 @@ PrefabInstance: m_SourcePrefab: {fileID: 100100000, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} --- !u!4 &2009655149 stripped Transform: - m_CorrespondingSourceObject: {fileID: 8768991388683709944, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3} - m_PrefabInstance: {fileID: 736274573} + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} ---- !u!1001 &2010853386 -PrefabInstance: + m_GameObject: {fileID: 327689120} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 708734976} + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &327689122 +MonoBehaviour: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: @@ -1943,55 +1954,55 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 327689121} + m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994344, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} + propertyPath: m_Name + value: Player + objectReference: {fileID: 0} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_RootOrder value: 1 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalPosition.x - value: -92.17318 + value: 1 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalPosition.y - value: -60.5 + value: 2.84 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalPosition.z - value: -48.028496 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalRotation.w value: 1 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalRotation.x - value: -0 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalRotation.y - value: -0 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalRotation.z - value: -0 + value: 0 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalEulerAnglesHint.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709944, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 8768991388683709947, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} - propertyPath: m_Name - value: Cube (1) - objectReference: {fileID: 0} m_RemovedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 32d2ba4971e4c7e4ab98a1f9c37dcffc, type: 3} + m_SourcePrefab: {fileID: 100100000, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs new file mode 100644 index 0000000..49180a1 --- /dev/null +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ProceduralGeneration : MonoBehaviour +{ + public List levelBlocks = new List(); + 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(); + 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() + { + + } +} diff --git a/Assets/Scripts/ProceduralGeneration.cs.meta b/Assets/Scripts/ProceduralGeneration.cs.meta new file mode 100644 index 0000000..87d504d --- /dev/null +++ b/Assets/Scripts/ProceduralGeneration.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b968982a4fb5e5e469b75c7d5c4abb25 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: