Question by 
               SirTweaksTheThird · Oct 12, 2016 at 07:22 AM · 
                timesounddelay  
              
 
              How do I delay a function to match the duration of a sound clip?
I working on a script that delays a function while a song plays.
Here is my code
function Update() {
 if(Input.GetKeyDown(KeyCode.E))
 {
 
               var audio: AudioSource = GetComponent.(); var startTime; var timer:int;
     audio.Play();
         
         function TimerStart()
     {    
         
             startTime = Time.time;
             timer = Time.time;
         
 if(timer >= 8)
         {
         print ("E has been pressed");
         }
     }
 }
 
               }
For the sake of making the debugging easier I've inserted print instead of a different function. Just until I see how the rest of the code works or is working.
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Parsing error CS8205,Parsing Error CS8205 2 Answers
Time delay enemy respawn 3 Answers
Delay in time 0 Answers
Loop sound from the middle to the end 1 Answer
Distance delay for sound 3 Answers