private void OnTriggerEnter(Collider other) { if (other.name == "player" && isTriggered == false) { // Disable second-time triggering. isTriggered = true; // Enable sub-scene. mySceneManagerRef.EnableSubScene(1); // Destroy the switch itself. Destroy(this.gameObject); } }
private void Awake() { // Init the first sub-scene and disable the rest. mySceneManager = this.GetComponent <MySceneManager>(); mySceneManager.EnableSubScene(0); for (int i = 1; i < mySceneManager.size; i++) { mySceneManager.DisableSubScene(i); } // Init attached components. audioManager = this.GetComponent <AudioManager>(); playerTrnsfrm = player.GetComponent <Transform>(); spiderTrnsfrm = spider.GetComponent <Transform>(); playerHeroRef = player.GetComponent <Hero>(); spiderRef = spider.GetComponent <Spider>(); cController = player.GetComponent <CharacterController>(); fpController = player.GetComponent <FirstPersonController>(); // Save the game on game start. SaveGame(); }
private void OnTriggerEnter(Collider other) { if (other.name == "player" && isTriggered == false) { // Disable second-time triggering. isTriggered = true; // Display the locked door. door.SetActive(true); // Play the door shutting audio. audioSource.PlayOneShot(audioDrag); Invoke("AudioPlayDoorShut", 1.0f); // Destroy sub-scene. mySceneManagerRef.DeleteSubScene(1); // Enable sub-scene. mySceneManagerRef.EnableSubScene(3); // Destroy the switch itself. Destroy(this.gameObject, 3.0f); } }