Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

what function call by update ?

Discussion in 'Scripting' started by athgen113, Aug 11, 2018.

  1. athgen113

    athgen113

    Joined:
    May 25, 2018
    Posts:
    25
    my game is over when tranfrom.possition.y<3f and i add in function Update but now i want add audio.playoneshot ,it not work by update alway call . how can i fix
     
  2. athgen113

    athgen113

    Joined:
    May 25, 2018
    Posts:
    25
    @Doug_B can you help me ,i fix done my ads ^^
     
  3. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,088
    Excellent news! Well done. :D

    If I understand you correctly, you want to play a sound when the game is over. You only want the sound to play once. Is that correct?

    If so, then you could add
    bool m_hasEndMusicPlayed;
    and only play the audio if that value is false (obviously set it to true when playing the audio for the first time).
     
  4. athgen113

    athgen113

    Joined:
    May 25, 2018
    Posts:
    25
    thank you so much , so how play audio music ? when i play music on , and if(tranfrom.positon.y<3f){ music off , dead audio on} ?
     
  5. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,088
    You just need to follow the Unity instructions on how to do this. You should have an audio listener attached to your main camera by default which will pick up the audio when it is played.
     
  6. athgen113

    athgen113

    Joined:
    May 25, 2018
    Posts:
    25
    thank you ,i did . i use a variable bool to check and it work ^^
     
    Doug_B likes this.