public void ActivateSwitch() { anim.SetBool("Trigger", true); anim.SetBool("Activate", true); AudioSource.PlayClipAtPoint(Sound1, transform.position); StopAnim = true; isTriggered = true; foreach (GameObject door in Doors) { door.SendMessage("UnlockDoor"); } if (isRespawner) { int i = 0; foreach (GameObject LookupItem in LookupObjects) { LookupItem.transform.position = ObjectPos[i]; i++; if (LookupItem.CompareTag("PlatForm")) { LookupItem.GetComponent <MoveingPlatform>().isMoving = false; } } } }
void OnTriggerEnter(Collider other) { Interactions++; if (Interactions >= 1 && isSwitch == false) { FindDoors(); isTriggered = true; foreach (GameObject door in Doors) { door.SendMessage("UnlockDoor"); } //anim.Play(Animation1, -1, 0f); anim.SetBool("Triggered", true); AudioSource.PlayClipAtPoint(Sound1, transform.position); } if (isRespawner && other.gameObject.CompareTag("Player")) { anim.Play(Animation1, -1, 0f); AudioSource.PlayClipAtPoint(Sound1, transform.position); int i = 0; foreach (GameObject LookupItem in LookupObjects) { LookupItem.transform.position = ObjectPos[i]; if (LookupItem.CompareTag("PlatForm")) { LookupItem.GetComponent <MoveingPlatform>().isMoving = false; } i++; } } if (isEventTrigger) { anim.Play(Animation1, -1, 0f); AudioSource.PlayClipAtPoint(Sound1, transform.position); foreach (GameObject LookupItem in LookupObjects) { LookupItem.GetComponent <MoveingPlatform>().isMoving = false; } } }
void OnTriggerExit(Collider other) { Interactions -= 1; if (Interactions <= 0 && isSwitch == false) { isTriggered = false; foreach (GameObject door in Doors) { door.SendMessage("LockDoor"); } anim.SetBool("Triggered", false); anim.SetBool("Deactivate", true); //anim.Play(Animation2, -1, 0f); //AudioSource.PlayClipAtPoint(Sound2, transform.position); } if ((Interactions <= 0 && isSwitch == false && isEventTrigger)) { isTriggered = false; foreach (GameObject LookupItem in LookupObjects) { LookupItem.GetComponent <MoveingPlatform>().StartMoving(); } } if (Interactions <= 0 && isRespawner) { foreach (GameObject LookupItem in LookupObjects) { if (LookupItem.CompareTag("PlatForm")) { LookupItem.GetComponent <MoveingPlatform>().StartMoving(); } } } }