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_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

View File

@ -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<Rigidbody>();
}
@ -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<Renderer>().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;
}
}