From be850a3795a08f022cea0043d28fe8e28e5441ef Mon Sep 17 00:00:00 2001 From: Programmer-DField Date: Tue, 2 Mar 2021 19:47:28 +0000 Subject: [PATCH] Changes made as per code review. --- game/Assets/Scenes/Main.unity | 16 ++++++++++++++++ game/Assets/Scripts/Traps/FallawayFloor.cs | 13 ++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/game/Assets/Scenes/Main.unity b/game/Assets/Scenes/Main.unity index 7913970..72297ce 100644 --- a/game/Assets/Scenes/Main.unity +++ b/game/Assets/Scenes/Main.unity @@ -710,6 +710,14 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 684295984} m_Modifications: + - target: {fileID: 980120856895548939, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3} + propertyPath: fallAwayTime + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 980120856895548939, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3} + propertyPath: destroyObjectTime + value: 1 + objectReference: {fileID: 0} - target: {fileID: 8144920974147422729, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3} propertyPath: m_RootOrder value: 0 @@ -3342,6 +3350,14 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 684295984} m_Modifications: + - target: {fileID: 980120856895548939, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3} + propertyPath: fallAwayTime + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 980120856895548939, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3} + propertyPath: destroyObjectTime + value: 5 + objectReference: {fileID: 0} - target: {fileID: 8144920974147422729, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3} propertyPath: m_RootOrder value: 1 diff --git a/game/Assets/Scripts/Traps/FallawayFloor.cs b/game/Assets/Scripts/Traps/FallawayFloor.cs index dc75982..c9412e2 100644 --- a/game/Assets/Scripts/Traps/FallawayFloor.cs +++ b/game/Assets/Scripts/Traps/FallawayFloor.cs @@ -4,12 +4,18 @@ using UnityEngine; public class FallawayFloor : MonoBehaviour { + // Speed at which the object moves towards the ground. public float speed; + // Time it takes for ogjecct to begin moving towards the ground. + public float fallAwayTime; + // Time taken for object to be destroyed. + public float destroyObjectTime; public Material dissolve; Rigidbody rb; private void Start() { + // Get Rigidbody component. rb = GetComponent(); } @@ -17,6 +23,7 @@ public class FallawayFloor : MonoBehaviour { if (other.gameObject.CompareTag("Player")) { + // Start the Destroy floor coroutine and switch to the dissolve material. StartCoroutine(DestroyFloor()); GetComponent().material = dissolve; } @@ -24,11 +31,11 @@ public class FallawayFloor : MonoBehaviour IEnumerator DestroyFloor() { - yield return new WaitForSeconds(1f); + // Take fallAwayTime, speed, and destroyObjectTime from editor and apply + yield return new WaitForSeconds(fallAwayTime); rb.velocity = Vector3.down * speed; - yield return new WaitForSeconds(1); + yield return new WaitForSeconds(destroyObjectTime); Destroy(gameObject); - yield return null; } }