/* * ------------------------------------------------------------------------ * Description: This class handles the teleporting system * Author: Eli Simpkins-Simmonds * ------------------------------------------------------------------------ */ using UnityEngine; [System.Serializable] public class TeleportDestination { public Transform playerLocation; // The location where the player will teleport to public Transform cameraLocation; // The location where the camera will teleport to } public class TeleportManager : MonoBehaviour { public TeleportDestination[] teleportDestinations; // Array of teleport destinations private int nextSpawnIndex = 0; // Index of the next spawn location void Start() { // Initialize nextSpawnIndex to a valid location if there are teleport destinations nextSpawnIndex = teleportDestinations.Length > 0 ? 0 : -1; } public void UpdateNextSpawnLocation(int lastTeleportIndex) { // Update the next spawn index to the next location in the array, wrapping around if necessary nextSpawnIndex = (lastTeleportIndex + 1) % teleportDestinations.Length; } public Transform GetNextSpawnLocation() { // Return the player location of the next spawn destination if the index is valid if (nextSpawnIndex >= 0 && nextSpawnIndex < teleportDestinations.Length) { return teleportDestinations[nextSpawnIndex].playerLocation; } return null; // Return null if the index is invalid } }