using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Avalanche : MonoBehaviour
{
    public float tempo;
    public GameObject preda;
     
    public float nextPedra;


    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
        if (Time.time > nextPedra)
        {
            nextPedra = Time.time + nextPedra;
            GameObject spawnadordePreda = Instantiate(preda, transform.position, Quaternion.identity);
            spawnadordePreda.AddComponent<DestroyOnCollision>();
        }
    }
    public class DestroyOnCollision : MonoBehaviour
{
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Destroy(gameObject);
    }
}
   
}
