From bae2df3fd8fa56021eee4e7aa90798e4d43c4ac9 Mon Sep 17 00:00:00 2001 From: haitem Date: Sat, 29 Jan 2022 20:12:11 +0100 Subject: [PATCH 1/3] Change some prefabs platform and player reaction --- Assets/Prefabs/platforms/Platform_Blue.prefab | 4 ++-- Assets/Prefabs/platforms/Platform_Green.prefab | 2 +- Assets/Prefabs/platforms/Platform_Orange.prefab | 2 +- Assets/Prefabs/platforms/Platform_Red.prefab | 4 ++-- Assets/Prefabs/platforms/Platform_yellow.prefab | 2 +- Assets/Scripts/PlatformManager.cs | 2 +- Assets/Scripts/PlayerController.cs | 2 ++ 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Assets/Prefabs/platforms/Platform_Blue.prefab b/Assets/Prefabs/platforms/Platform_Blue.prefab index 1597bfa..6d95cde 100644 --- a/Assets/Prefabs/platforms/Platform_Blue.prefab +++ b/Assets/Prefabs/platforms/Platform_Blue.prefab @@ -198,8 +198,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fdc803964e5f2b042bece1765b69164f, type: 3} m_Name: m_EditorClassIdentifier: - type: 0 - speed: 5 + type: 2 + speed: 10 --- !u!65 &8238111678033492397 BoxCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/platforms/Platform_Green.prefab b/Assets/Prefabs/platforms/Platform_Green.prefab index 1fede84..b3e0e3a 100644 --- a/Assets/Prefabs/platforms/Platform_Green.prefab +++ b/Assets/Prefabs/platforms/Platform_Green.prefab @@ -199,7 +199,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fdc803964e5f2b042bece1765b69164f, type: 3} m_Name: m_EditorClassIdentifier: - type: 1 + type: 0 speed: 5 --- !u!65 &3865253352867341094 BoxCollider: diff --git a/Assets/Prefabs/platforms/Platform_Orange.prefab b/Assets/Prefabs/platforms/Platform_Orange.prefab index 8c13c1e..fea00cb 100644 --- a/Assets/Prefabs/platforms/Platform_Orange.prefab +++ b/Assets/Prefabs/platforms/Platform_Orange.prefab @@ -198,7 +198,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fdc803964e5f2b042bece1765b69164f, type: 3} m_Name: m_EditorClassIdentifier: - type: 5 + type: 6 speed: 10 --- !u!65 &6218203028538785626 BoxCollider: diff --git a/Assets/Prefabs/platforms/Platform_Red.prefab b/Assets/Prefabs/platforms/Platform_Red.prefab index 58c1c3f..754bd50 100644 --- a/Assets/Prefabs/platforms/Platform_Red.prefab +++ b/Assets/Prefabs/platforms/Platform_Red.prefab @@ -198,8 +198,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fdc803964e5f2b042bece1765b69164f, type: 3} m_Name: m_EditorClassIdentifier: - type: 0 - speed: 5 + type: 1 + speed: 10 --- !u!65 &5316890779910729157 BoxCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/platforms/Platform_yellow.prefab b/Assets/Prefabs/platforms/Platform_yellow.prefab index 1810a8f..6273bc5 100644 --- a/Assets/Prefabs/platforms/Platform_yellow.prefab +++ b/Assets/Prefabs/platforms/Platform_yellow.prefab @@ -198,7 +198,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fdc803964e5f2b042bece1765b69164f, type: 3} m_Name: m_EditorClassIdentifier: - type: 4 + type: 5 speed: 10 --- !u!65 &4344779564172896453 BoxCollider: diff --git a/Assets/Scripts/PlatformManager.cs b/Assets/Scripts/PlatformManager.cs index e97b02e..c398c64 100644 --- a/Assets/Scripts/PlatformManager.cs +++ b/Assets/Scripts/PlatformManager.cs @@ -4,7 +4,7 @@ using UnityEngine; public class PlatformManager : MonoBehaviour { - public enum PlatformType {Pull, Push, RotateZ, RotateY, SpeedUp, SpeedDown}; + public enum PlatformType {Basic, Pull, Push, RotateZ, RotateY, SpeedUp, SpeedDown}; public PlatformType type = PlatformType.Pull; public float speed = 5; diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 66ffb66..2485f51 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -178,8 +178,10 @@ public class PlayerController : MonoBehaviour switch (platform.type) { case PlatformManager.PlatformType.Push: + rb.AddExplosionForce(platform.speed * Time.deltaTime * 10, other.gameObject.transform.position, 10); break; case PlatformManager.PlatformType.Pull: + rb.AddExplosionForce(-platform.speed * Time.deltaTime * 10, other.gameObject.transform.position, 10); break; case PlatformManager.PlatformType.RotateY: break; From 35c93c6a4b7c0d4b922771eaf61549939743aff9 Mon Sep 17 00:00:00 2001 From: GamerClassN7 Date: Sat, 29 Jan 2022 20:15:14 +0100 Subject: [PATCH 2/3] Procedural Generation --- Assets/Scripts/ProceduralGeneration.cs | 27 +++++++++++--------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs index aee77a2..5500641 100644 --- a/Assets/Scripts/ProceduralGeneration.cs +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -30,7 +30,14 @@ 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 + 3.0f); + + MeshFilter meshfilter = lastObject.GetComponent(); + Bounds bounds = meshfilter.mesh.bounds; + + float scale = meshfilter.transform.localScale.x; + Bounds b = new Bounds(bounds.center * scale, bounds.size * scale); + + Vector3 centerPoint = new Vector3(lastObject.transform.position.x, (lastObject.transform.position.y + radius), this.lastBlock.transform.position.z + b.size.z + 1.0f); float heightOffset = radius; @@ -73,7 +80,7 @@ public class ProceduralGeneration : MonoBehaviour if (this.spawnedLevelBlocks.Count <= maxNumberOfBlock) { - int blockToSpawn = Random.Range(0, levelBlocks.Count - 1); + int blockToSpawn = Random.Range(0, levelBlocks.Count); GameObject instantiatedGameObject; GameObject blockObjToSpawn; @@ -82,21 +89,9 @@ public class ProceduralGeneration : MonoBehaviour if (blockObjToSpawn.name == lastBlockPrefab.name) { Debug.Log("Same Block"); - if ((blockToSpawn + 1) <= levelBlocks.Count) + if (blockToSpawn < levelBlocks.Count || blockToSpawn > -1) { - blockToSpawn++; - } - else if ((blockToSpawn - 1) >= levelBlocks.Count) - { - blockToSpawn--; - } - if ((blockToSpawn + 1) <= levelBlocks.Count) - { - blockToSpawn++; - } - else if ((blockToSpawn - 1) >= levelBlocks.Count) - { - blockToSpawn--; + blockToSpawn = Random.Range(0, (levelBlocks.Count - 1)); } } From 62f648cfb5556dbdccd06d670cf1c73457fe6898 Mon Sep 17 00:00:00 2001 From: haitem Date: Sat, 29 Jan 2022 20:27:34 +0100 Subject: [PATCH 3/3] Edit some push and pull --- Assets/Scripts/PlayerController.cs | 8 ++++---- UserSettings/EditorUserSettings.asset | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 2485f51..900c10f 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -178,10 +178,10 @@ public class PlayerController : MonoBehaviour switch (platform.type) { case PlatformManager.PlatformType.Push: - rb.AddExplosionForce(platform.speed * Time.deltaTime * 10, other.gameObject.transform.position, 10); + rb.AddForce(other.GetContact(0).normal * platform.speed * Time.deltaTime, ForceMode.Impulse); break; case PlatformManager.PlatformType.Pull: - rb.AddExplosionForce(-platform.speed * Time.deltaTime * 10, other.gameObject.transform.position, 10); + rb.AddForce(-other.GetContact(0).normal * platform.speed * Time.deltaTime, ForceMode.Impulse); break; case PlatformManager.PlatformType.RotateY: break; @@ -198,11 +198,11 @@ public class PlayerController : MonoBehaviour } break; default: - gDirection = -transform.up; + gDirection = -other.GetContact(0).normal; break; } } else { - gDirection = -transform.up; + gDirection = -other.GetContact(0).normal; } platformForward = other.transform.forward; this.downDirection = gDirection; diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 8158427..7fbf7c2 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -9,11 +9,14 @@ EditorUserSettings: value: 5150040003515f5f585f552011755e4446154e2e2a2a7e347c2c4965b1b4366a flags: 0 RecentlyUsedSceneGuid-1: - value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a + value: 50080c5756540a5e095b0d7a11210644154f1b7f782922642f281b35b0b86c6d flags: 0 RecentlyUsedSceneGuid-2: value: 5b53500307070b0b0b0f5a2648735a4412154f737d2b2536782f1e32e0b86c3a flags: 0 + RecentlyUsedSceneGuid-3: + value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a + flags: 0 RecentlyUsedScenePath-0: value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d flags: 0