Untitled

 avatar
unknown
plain_text
15 days ago
871 B
2
Indexable
using UnityEngine;

public class MapLoader : MonoBehaviour
{
    public GameObject forestMap;
    public GameObject cityMap;
    public GameObject mountainsMap;
    public GameObject canyonsMap;
    public GameObject cavesMap;
    public Transform spawnPoint;

    void Start()
    {
        LoadMap(forestMap);
    }

    void LoadMap(GameObject map)
    {
        Instantiate(map, spawnPoint.position, Quaternion.identity);
    }

    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("City"))
        {
            LoadMap(cityMap);
        }
        else if (other.CompareTag("Mountains"))
        {
            LoadMap(mountainsMap);
        }
        else if (other.CompareTag("Canyons"))
        {
            LoadMap(canyonsMap);
        }
        else if (other.CompareTag("Caves"))
        {
            LoadMap(cavesMap);
        }
    }
}
Editor is loading...
Leave a Comment