I followed Brackeys tutorial on how to add sound but at one point i got an error that he didnt. Here is the error
ArgumentNullException: Value cannot be null.
Parameter name: source
UnityEngine.AudioSource.Play () (at <7117d168a9ec4e518e0de7d9c98bd09a>:0)
audioManager.Play (System.String name) (at Assets/scripts/Sound/audioManager.cs:23)
Enemy.FixedUpdate () (at Assets/scripts/Game/Enemy.cs:88)
and here are is the audio manager code any help would be appreciate it
public class audioManager : MonoBehaviour
{
public Sound[] sounds;
public Enemy enemy;
public bool sempty;
void Awake()
{
foreach(Sound s in sounds){
s.source = gameObject.AddComponent<AudioSource>();
s.source.clip = s.clip;
s.source.volume = s.volume;
s.source.pitch = s.pitch;
}
}
public void Play(string name){
Sound s = Array.Find(sounds, Sound => Sound.AudioName == name);
s.source.Play();
}
}
and here is the part where im trying to play the sound
public Animator animator;
public audioManager audio;
public bool damaged = false;
public IEnumerator Blood(){
yield return new WaitForSeconds(0.05f);
damaged = false;
}
if (damaged == true){
blood.Play();
StartCoroutine(Blood());
audio.Play("peos");
}
the part where the damaged variable changes to true is on another script