//This trigger opens the elevator when the player has returned with the keycard //There is a small delay between playing the animation and when the player is moved down void OnTriggerStay(Collider other) { if (other.gameObject.tag == "Player") { if (key == true) { Elevator.enabled = true; Timer = Timer - Time.deltaTime; if (Timer <= 0) { other.transform.position = new Vector2(84.50f, -40f); audioVolume.PlayMusic(); } Debug.Log("Move"); } else { Debug.Log("No Key"); } } }
//When the player enters the elevator it will play the correct sound and also disables the colliders //This is done so the sound does not continue when the player goes back to it void OnTriggerEnter(Collider Other) { if (Other.gameObject.tag == "Player") { audioVolume.PlayMusic(); Elevator.SetBool("Play", true); GetComponent <Collider>().enabled = false; } }
//This plays a sound as well as an animation then the box collider is turned off so that the user can't make the sound go off again void OnTriggerEnter(Collider Other) { if (Other.gameObject.tag == "Player") { audioVolume.PlayMusic(); anim.enabled = true; GetComponent <Collider>().enabled = false; } }
void OnCollisionEnter(Collision coll) { //if enemies hit self or other enemies ignore for gravity if (coll.gameObject.tag == "Enemy") { } else if (coll.gameObject.tag == "Claw") { Destroy(this); } else { //turn gravity sound on RB.useGravity = true; audioVolume.PlayMusic(); } }
// Use this for initialization void Start() { audioVolume.PlayMusic(); }