public class water : MonoBehaviour {
public AudioClip drown;
void OnTriggerEnter(Collider otherObject)
{
if (otherObject.gameObject.tag == "Player")
{
Destroy(otherObject.gameObject, 0.3f);
audio.Play();
PauseScript.playerLives--;
if (PauseScript.playerLives > 0)
{
Application.LoadLevel(Application.loadedLevel);
}
else
{
Application.LoadLevel(0);
}
}
}
}
After the above script I drag and drop my wav file on to the audioclip variable drown in Unity interface. But when I play the game I get this error -- there is no audiosource attached to the game object, but a script is trying to access it.