private void OnTriggerStay(Collider other) { if (other.name == "Player") { playerController.ReturnToCheckpoint(); } }
private void LoadData() { LevelData0 data = (LevelData0)SaveSystem.LoadLevel(); if (data == null || data.Level != Level) { SafeData(); return; } foreach (int enemyID in data.deadEnemies) { Destroy(livingEnemies.Find(x => x.name == "Enemy " + enemyID)); } playerHealth.SetHealth(data.health, data.maxHealth); ownedGuns = new List <GunScript>(); foreach (Transform child in player.transform.Find("First Person Camera")) { if (child.name.StartsWith("Gun ")) { Destroy(child.gameObject); } } for (int i = 0; i < data.guns.Length; i++) { GunScript gun = Instantiate(GetGun(data.guns[i]), player.transform.Find("First Person Camera")); gun.name = gun.name.Replace("(Clone)", ""); ownedGuns.Add(gun); gun.SetAmmo(data.ammo[i]); if (data.gunsActive[i]) { currentGun = gun; } else { gun.gameObject.SetActive(false); } } playerController.lastCheckpoint = GameObject.Find("Checkpoint " + data.checkpoint).transform; playerController.ReturnToCheckpoint(); Debug.Log("Loaded safe file at " + SaveSystem.path); }