I am trying to make it so that always the audio is the “breathing walking” sound and when i press sprint button then the audio is “breathing running”.
I tried using audio.Play and Input.GetButton but it doesn’t work.
I am trying to make it so that always the audio is the “breathing walking” sound and when i press sprint button then the audio is “breathing running”.
I tried using audio.Play and Input.GetButton but it doesn’t work.
Use Input.KeyDown
function Update(){
if(Input.KeyDown("shift")){
audio.Play
}
if(Input.KeyUp("shift")){
audio.Stop
}
}
AudioSources audioClips = GetComponents();
bool Sprinting = false;
if (input.getbutton("sprint"){
sprinting = true
}
if(sprinting){
audioClips[0].stop;
//now do a duration check
//so you know when to play
//the clip again. if so
audioClips[1].play;
}
getcomponents();
gets all audiosources attached as an array;
you can then access each audio source individually to stop and start various ones