playoneshot unity code example
Example: unity audio source playoneshot
public AudioClip impact;
AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
}
void OnCollisionEnter()
{
audioSource.PlayOneShot(impact, 0.7F);
}