void OnTriggerStay(Collider obj) { if (obj.CompareTag("Player") || obj.CompareTag("Weapon")) { // If it's an unlockable door not a normal one if (tag == "LockUnlockDoor") { canView = true; // If the player's inventory has the key or it's open already Door_LockUnlock door = GetComponent <Door_LockUnlock>(); if (door == null) { Debug.LogError("You probably forgot to add a door_Lock_Unlock script"); } if (door.playerHasMatchingKey() || door.open) { canView = false; canTeleport = !canView; } } // Normal door else { canView = false; canTeleport = true; } } }
private void CheckTeleported() { // We've been teleported to the new position if (Time.time >= fadeTimer + durationToFade / 2 && fadeTimer != 0.0f) { // Move player to pos player.transform.position = posOfPlace; // Handle camera changes cameraManager.DeactivateAllCameras(); cameraToMoveTo.SetActive(true); // Handle state changes player_controller.isTeleporting = false; canTeleport = false; // Handle timer changes fadeTimer = 0.0f; // Change door state if not opened if (tag == "LockUnlockDoor") { Door_LockUnlock door = GetComponent <Door_LockUnlock>(); // Haven't opened door yet if (!door.open) { door.setDoorOpen(true); player_controller.inventoryHandler.removeKeyWithID(door.DoorID); } } // Set respawn values player_controller.spawnPos.position = posOfPlace; player_controller.cameraRespawnLookingAtPlayer = cameraToMoveTo; } }