Sorry if this has already been posted about. I’m not very good with the audio side of things, and I’m trying to get it so that, when an object hits a different the walls, the same sound is made. However, all the tutorials on the subject that I have come across so far, have only helped in playing the sound once, and then never again afterward.
This is my most recent attempt:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class SoundOnCollision : MonoBehaviour {
public AudioSource audio;
void Start() {
audio = GetComponent<AudioSource>();
}
void OnCollisionEnter (Collider other)
{
if (other.gameObject.tag == "Wall 2") {
audio.Play();
}
}
}
Any chance I could get some advice? Thanks in advance!