Changes made as per code review.

This commit is contained in:
Programmer-DField 2021-03-02 19:47:28 +00:00
parent 0e6d9f2a8b
commit be850a3795
2 changed files with 26 additions and 3 deletions

View File

@ -710,6 +710,14 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 684295984} m_TransformParent: {fileID: 684295984}
m_Modifications: 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} - target: {fileID: 8144920974147422729, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 0 value: 0
@ -3342,6 +3350,14 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 684295984} m_TransformParent: {fileID: 684295984}
m_Modifications: 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} - target: {fileID: 8144920974147422729, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 1 value: 1

View File

@ -4,12 +4,18 @@ using UnityEngine;
public class FallawayFloor : MonoBehaviour public class FallawayFloor : MonoBehaviour
{ {
// Speed at which the object moves towards the ground.
public float speed; 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; public Material dissolve;
Rigidbody rb; Rigidbody rb;
private void Start() private void Start()
{ {
// Get Rigidbody component.
rb = GetComponent<Rigidbody>(); rb = GetComponent<Rigidbody>();
} }
@ -17,6 +23,7 @@ public class FallawayFloor : MonoBehaviour
{ {
if (other.gameObject.CompareTag("Player")) if (other.gameObject.CompareTag("Player"))
{ {
// Start the Destroy floor coroutine and switch to the dissolve material.
StartCoroutine(DestroyFloor()); StartCoroutine(DestroyFloor());
GetComponent<Renderer>().material = dissolve; GetComponent<Renderer>().material = dissolve;
} }
@ -24,11 +31,11 @@ public class FallawayFloor : MonoBehaviour
IEnumerator DestroyFloor() 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; rb.velocity = Vector3.down * speed;
yield return new WaitForSeconds(1); yield return new WaitForSeconds(destroyObjectTime);
Destroy(gameObject); Destroy(gameObject);
yield return null;
} }
} }