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

public class terrainToCave : MonoBehaviour
{
    public bool Left = true;

    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player" && Left == true)
        {
            if (SceneManager.GetActiveScene().name == "Terrain")
            {
                SceneManager.LoadScene("cave");
            }
            else if (SceneManager.GetActiveScene().name == "cave")
            {
                SceneManager.LoadScene("Terrain");
            }
            Left = false;
        }
    }

    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
            Left = true;
        }
    }
}
