Hello everyone,
am trying to play a simple audio in my game, i have a cube object with only this script :
using UnityEngine;
using System.Collections;
public class testSound : MonoBehaviour
{
public AudioClip loose ;
// Use this for initialization
void Start ()
{
audio.PlayOneShot(loose);
}
// Update is called once per frame
void Update ()
{
}
}
and in the inspector i added the sound file to the component, how ever each time i got this error :
There is no ‘AudioSource’ attached to
the “Cube” game object, but a script
is trying to access it. You probably
need to add a AudioSource to the game
object “Cube”. Or your script needs to
check if the component is attached
before using it.
thank you