using System.Collections; using System.Collections.Generic; using UnityEngine; public class LoopedRoom : MonoBehaviour { public GameObject[] _room; public Transform _LoopTeleportPoint; public Transform LoopTriggerTeleportPoint; public Transform _player; //Just for debugging change later. public bool CanChangeLoop; public bool ChangeLoopedRoom; public int CurrentRoomLoopID; public int PreviousRoomLoopID; public int NextRoomLoopID; [HideInInspector] public bool LoadNextRoom = true; [HideInInspector] public bool UpdateTeleportPOS = true; // Update is called once per frame void Update() { NextLoopActivation(); } public void NextLoopActivation() { if (ChangeLoopedRoom) { _room[PreviousRoomLoopID].SetActive(false); _room[CurrentRoomLoopID].SetActive(true); if (LoadNextRoom) //If LoadNextRoom is set to true: { _room[NextRoomLoopID].SetActive(true); } if (UpdateTeleportPOS) //If UpdateTeleportPOS is set to true then update the room's teleport position: { _room[CurrentRoomLoopID].transform.position = _LoopTeleportPoint.transform.position; _room[CurrentRoomLoopID].transform.rotation = _LoopTeleportPoint.transform.rotation; } ChangeLoopedRoom = false; //CanChangeLoop = false; } } }