how to play a sound in unity code example
Example 1: play sound unity
AudioSource audioData;
void Start()
{
audioData = GetComponent<AudioSource>();
audioData.Play(0);
Debug.Log("started");
}
Example 2: how to play sound in unity
public AudioSource Jump;
Jump.Play();
Example 3: play sound on collision unity c#
void Start ()
{
saw = GameObject.FindObjectOfType<AudioSource>();
}
void Update ()
{
}
void OnCollisionEnter(Collision col)
{
if(col.gameObject)
{
saw.Play();
Debug.Log("Nurrrr");
}
}