using UnityEngine; public class HubReturnManager : MonoBehaviour { void Start() { // Restore player position GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player != null && HubReturnData.lastDoorIndex >= 0) player.transform.position = HubReturnData.lastDoorPosition; // Close the door if the level was completed if (HubReturnData.lastDoorIndex >= 0 && WorldProgress.levelsCompleted[HubReturnData.lastDoorIndex]) { foreach (var door in FindObjectsByType(FindObjectsSortMode.None)) { if (door.levelIndex == HubReturnData.lastDoorIndex) door.CloseDoor(); } } // Reset for next use HubReturnData.lastDoorIndex = -1; } }