revival/game/Assets/FallawayFloor.cs

32 lines
607 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FallawayFloor : MonoBehaviour
{
public float speed;
Rigidbody rb;
private void Start()
{
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);
yield return null;
}
}