What I want to happen is that whenever an object passes over the empty objects with 2d box colliders titled - left, right, and middle - a sound will be played. My collisions work (I have tested them with Debug.Log) but my sound wont play. My script is
var beep : AudioClip;
function OnTriggerEnter2D() {
audio.PlayOneShot(beep);
}
I dragged the sound into the inspector, and to my knowledge this should work. When I run my game, an error appears that says
MissingComponentException: There is no ‘AudioSource’ attached to the “Right” game object, but a script is trying to access it.
You probably need to add a AudioSource to the game object “Right”. Or your script needs to check if the component is attached before using it.
UnityEngine.AudioSource.PlayOneShot (UnityEngine.AudioClip clip) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/AudioBindings.cs:499)
Beep.OnTriggerEnter2D () (at Assets/Scripts/Audio/Beep.js:6)
It says I need to attach an Audio Source, but to my knoweledge, I shouldn’t have to. If I do need to attach an audio source, how to I disable all of the complex 3d capabilities and get it to work.