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".

This commit is contained in:
Programmer-DField 2021-02-25 00:51:11 +00:00
parent 83cd280778
commit 1f4c063c60
2 changed files with 27 additions and 7 deletions

View File

@ -4,9 +4,28 @@ using UnityEngine;
public class FallawayFloor : MonoBehaviour public class FallawayFloor : MonoBehaviour
{ {
IEnumerator OnCollisionEnter(Collision coll) public float speed;
Rigidbody rb;
private void Start()
{ {
yield return new WaitForSeconds(2); rb = GetComponent<Rigidbody>();
}
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); Destroy(gameObject);
yield return null;
} }
} }

View File

@ -1310,7 +1310,7 @@ MeshRenderer:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1644003337} m_GameObject: {fileID: 1644003337}
m_Enabled: 0 m_Enabled: 1
m_CastShadows: 1 m_CastShadows: 1
m_ReceiveShadows: 1 m_ReceiveShadows: 1
m_DynamicOccludee: 1 m_DynamicOccludee: 1
@ -1543,7 +1543,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1995811568} m_GameObject: {fileID: 1995811568}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 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_LocalScale: {x: 3.1289, y: 0.13889, z: 6.7626376}
m_Children: [] m_Children: []
m_Father: {fileID: 2018660589} m_Father: {fileID: 2018660589}
@ -1560,8 +1560,8 @@ BoxCollider:
m_IsTrigger: 1 m_IsTrigger: 1
m_Enabled: 1 m_Enabled: 1
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1} m_Size: {x: 1, y: 1, z: 0.63}
m_Center: {x: 0, y: 1, z: 0} m_Center: {x: 0, y: 5.13, z: 0}
--- !u!23 &1995811571 --- !u!23 &1995811571
MeshRenderer: MeshRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1639,6 +1639,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 425c126c97ce3fb438fa3ef015d37317, type: 3} m_Script: {fileID: 11500000, guid: 425c126c97ce3fb438fa3ef015d37317, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
speed: 2
--- !u!65 &1995811575 --- !u!65 &1995811575
BoxCollider: BoxCollider:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0