Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Weird Problem: Audio (voice) won't trigger immediately, only when first-person camera looks down.

Discussion in 'Audio & Video' started by drp5205, Apr 16, 2015.

  1. drp5205


    Apr 16, 2015
    I'm trying to have dialogue between the first person avatar and another voice from a speaker (so no problems with animations), I know this may not be the best way to do this, but I have this code triggered by a Boolean and a function call:
    Code (JavaScript):
    1. function Dialogue0() {
    2.     rP1L01.SetActive(true);
    3.     yield WaitForSeconds (rP1L01File.length);
    4.     oP1L01.SetActive(true);
    5.     yield WaitForSeconds (oP1L01File.length);
    6.     rP1L02.SetActive(true);
    7.     yield WaitForSeconds (rP1L02File.length);
    8.     oP1L02.SetActive(true);
    9.     yield WaitForSeconds (oP1L02File.length);
    10.     rP1L03.SetActive(true);
    12.     transition0 = true;
    14. }
    "r" is speaking to "o" and the variable names refer to the script such as rPage1Line01 etc. The gameObjects are empty objects with audio source components and the "File" variables are AudioClips from .wav files. The load type is "Streaming." "Decompress on load" seems to run more slowly, and "Compressed in Memory" doesn't seem to work at all.

    When I run a trace, there seems to be an indefinite delay between when this starts and when the boolean is triggered (although once the first line runs--rP1L01--the rest follow up perfectly). Up to 30ish seconds (which really doesn't work for dialogue). However, it seems to be expedited when my avatar is looking down. Sometimes I can get it to work immediately, if my character is looking down right as the boolean is triggered, but other times there's still a distinct delay. I'd love to know if I'm doing this terribly wrong! Thank you!