play a audio sound on a collision code example
Example: how to play sound on collision unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ImpactTrigger : MonoBehaviour
{
AudioSource source;
void Start()
{
source = GetComponent<AudioSource>();
}
private void OnCollisionEnter(Collision collision)
{
source.Play();
}
}
//https://asyncaudio.com/blogs/tutorials/how-to-create-a-simple-audio-impact-collision-trigger-with-unity