I am adding audio files to my object in my script. I have done:-
I have dragged the Audio File which I have recorded to the inspector. But it is giving a compiler error as: "Cannot convert UnityEngine.AudoSource to UnityEngine.AudioClip." How to play it through the script. Help! Thanks in advance.
Well, it's pretty obvious that you have to make voice_1 an AudioClip, not an AudioSource!
More importantly, once you've done that, you can't just use the 'Play' method with an AudioClip. To play a clip at a point, you can use
Which will play a one-shot of that audio clip at the location of the object.
Basically, you need to change this line-
and it'll all work. How you use it is up to you, though.
answered Dec 22 '11 at 07:50 AM