- Home /
Help with sound clips [C#]
Hello guys, I want to ask you what is the best way to implement the audio part in a game. I explain better the question: I've got a lot of clips to play in the game and I need to play them inside an update function (because some of them must play in some moments, for example if a player press the left or right arrow etc). Let's say i've got 5 clips called myVoice1, 2 ,3 ,4, 5. My Main Camera has got an audio listener and one audio source. I declare inside my script one AudioSource variable and 5 public AudioClips that I assign through the inspector. I need these 5 clips to play correctly inside an update function(for correctly I mean that they should not play every frame of course) (for example, one if player is dead, another one if player press the right arrow etc). Also, I need that if 2 or more clips are called together, they should play one after another. How can I achieve this? I couldn't find anything helpful on google... Thank you in advance! PS: no clips are inside function like OnTRiggerEnter, OnCollisionEnter etc. Just inside update.
Can you post some sample code from your Update function (especially the input handling part)?
Your answer
![](https://koobas.hobune.stream/wayback/20220612111825im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to start a sound not from it's start ? 2 Answers
Playing a sound clip from another object 1 Answer
Calling sound once in update 1 Answer
Get audio from device... -1 Answers
Random, 3d sound. 1 Answer