Question by
goutham12 · Apr 04, 2019 at 11:28 AM ·
scripting problemaudioscripting beginneraudioplay
Question on Audio?
Hi there, Am doing a runner game. as you know a player is will collect lot no of coins in continuous. I have to play the when the player collecting coins in increment order. not like play sound on collection. I mean same like subway surfer. first coin sound is less and the next is a bit higher and so on.. how can I do it
Comment
Best Answer
Answer by Vollmondum · Apr 04, 2019 at 12:32 PM
public float pitchShiftValue;
public float pitchDefault;
public float pitchMax;
void OnCoinCollect()
{
myAudioSource.PlayOneShot(mySound);
if(myAudioSource.pitch < pitchMax)
{
myAudioSource.pitch += pitchShiftValue;
}
else
{
myAudioSource.pitch = pitchDefault;
}
}
Your answer
Follow this Question
Related Questions
change Volume of Audiomixergroups by script 1 Answer
AudioSource dissappears in variable window on Play 2 Answers
Change Audio Mixer through script for every scene 0 Answers
Flashlight flickering script? 0 Answers
Adding second player script? 1 Answer