play an AudioSource multipe times???

it’s an example to show the problem.

public AudioSource a;

void Update(){

so i have an audioSource.when i push F key,it plays the audio.but the problem is that if I push F when the audio is playing it will stop the audioSource and play it again at can I fix this problem???any solution?(it should play the audio multipe times)

@PersianKiller First you should check if AudioSource isPlaying , so you can add !a.isPlaying to your if statement if(Input.GetKeyDown(KeyCode.F) && !a.isPlaying )
then you can use a.Loop to play the audio multiple times

Hi @PersianKiller .
I’m not sure what you are trying to achieve but let me guess.
You want the audio to play whenever you press “f” and also “pause” if you press the key again?
Can you expatiate?


Use AudioSource.PlayClipAtPoint