- Home /
how to add a sound when collecting coins?
How do I add a sound when I pick up coins in game? This is the code I have already.
function OnCollisionEnter(hit : Collision) {
if(hit.transform.tag == "Coin") {
var cn : PauseGUI = this.GetComponent("PauseGUI");
cn.coins += 1;
coinsCollected += 1;
points += 100;
Destroy(hit.gameObject);
audio.clip = coinSnd;
audio.Play();
audio.volume = (5);
}
}
Comment
And this is not working? Is your audio set as 3D sound? If so, try uncheck this option Also, volume ranges from 0 to 1.
Your answer
Follow this Question
Related Questions
help with multiple sounds 0 Answers
Audio doesn't play 1 Answer
NGUI Volume And Quality Controle With Sliders Not working 1 Answer
Play from a variety of sounds? 1 Answer
Audio listener to mono then to left or right speaker? 2 Answers