- Home /
There is no 'audioSource' attached to the game object error
I type these at the top of one javascript :
public var mHitClip : AudioClip; @script RequireComponent(AudioSource)
And then in update(), I write: audio.PlayOneShot(mHitClip);
Then I drag an audio file to match the public variable. when runing, there is a error: There is no 'AudioSource' attached to the game object, but a script is trying to access it.
How to deal with this problem? Thank you for taking time reading this.
Answer by Jason B · Jun 23, 2011 at 02:33 PM
The error tells you exactly what the problem is and how to fix it. You have no Audio Source attached to the game object that this script is running on.
Same problem with my scipt also , and $$anonymous$$r Jason.B its something having problem with unity I think..I checked and rechecked the problem never goes..