Door open/close sound effect??
There is any way to play a random sound when open and close the door on press "e"? The close sound would be wait until the door end to close to play the sound.
 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(AudioSource))]
 public class Door_singleDoor : MonoBehaviour
 {
     public float smooth = 2.0f;
     public float DoorOpenAngle = 90.0f;
     public float DoorCloseAngle = 0.0f;
     public bool open;
     public bool enter;
 
     public AudioClip[] OpenStart;           // Sound for start open
     public AudioClip[] OpenEnd;             // Sound for finish open
     public AudioClip[] CloseStart;          // Sound for start close
     public AudioClip[] CloseEnd;            // Sound for finish close
 
     public AudioSource audio;
 
     void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.tag == "Player")
         {
             enter = true;
         }
     }
 
 
     void OnTriggerExit(Collider other)
     {
         if (other.gameObject.tag == "Player")
         {
             enter = false;
         }
     }
 
     void Update()
     {
         if (open == true)
         {
             var target = Quaternion.Euler(0, DoorOpenAngle, 0);
             transform.localRotation = Quaternion.Slerp(transform.localRotation, target, Time.deltaTime * smooth);
         }
 
         if (open == false)
         {
             var target1 = Quaternion.Euler(0, DoorCloseAngle, 0);
             transform.localRotation = Quaternion.Slerp(transform.localRotation, target1, Time.deltaTime * smooth);
         }
 
         if (enter == true)
         {
             if (Input.GetKeyDown("e"))
             {
                 open = !open;
             }
         }
     }
 }
 
              
               Comment
              
 
               
              Your answer