From 1f4c063c602d8ec42b73733bed706aa3d3f6dfb3 Mon Sep 17 00:00:00 2001 From: Programmer-DField Date: Thu, 25 Feb 2021 00:51:11 +0000 Subject: [PATCH] Updated the FallingFloor script. The floor now begins to lower, waits for a set period and then is destroyed. I plan to add a disssolve effect to make this transition look better. The player begins to slowly fall with the floor until the object is destroyed at which point the player falls with gravity hitting the sspike trap and "dying". --- game/Assets/FallawayFloor.cs | 25 ++++++++++++++++++++++--- game/Assets/Scenes/Main.unity | 9 +++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/game/Assets/FallawayFloor.cs b/game/Assets/FallawayFloor.cs index ad1747f..2780028 100644 --- a/game/Assets/FallawayFloor.cs +++ b/game/Assets/FallawayFloor.cs @@ -4,9 +4,28 @@ using UnityEngine; public class FallawayFloor : MonoBehaviour { - IEnumerator OnCollisionEnter(Collision coll) + public float speed; + Rigidbody rb; + + private void Start() { - yield return new WaitForSeconds(2); - Destroy(gameObject); + rb = GetComponent(); + } + + private void OnTriggerEnter(Collider other) + { + if (other.gameObject.tag == "Player") + { + StartCoroutine(DestroyFloor()); + } + } + + IEnumerator DestroyFloor() + { + rb.velocity = Vector3.down * speed; + yield return new WaitForSeconds(1); + + Destroy(gameObject); + yield return null; } } diff --git a/game/Assets/Scenes/Main.unity b/game/Assets/Scenes/Main.unity index c1c7432..72f17e2 100644 --- a/game/Assets/Scenes/Main.unity +++ b/game/Assets/Scenes/Main.unity @@ -1310,7 +1310,7 @@ MeshRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1644003337} - m_Enabled: 0 + m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -1543,7 +1543,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1995811568} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 10.216017, y: 5.48, z: -0.8434677} + m_LocalPosition: {x: 10.216017, y: 5.84, z: -0.8434677} m_LocalScale: {x: 3.1289, y: 0.13889, z: 6.7626376} m_Children: [] m_Father: {fileID: 2018660589} @@ -1560,8 +1560,8 @@ BoxCollider: m_IsTrigger: 1 m_Enabled: 1 serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 1, z: 0} + m_Size: {x: 1, y: 1, z: 0.63} + m_Center: {x: 0, y: 5.13, z: 0} --- !u!23 &1995811571 MeshRenderer: m_ObjectHideFlags: 0 @@ -1639,6 +1639,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 425c126c97ce3fb438fa3ef015d37317, type: 3} m_Name: m_EditorClassIdentifier: + speed: 2 --- !u!65 &1995811575 BoxCollider: m_ObjectHideFlags: 0