Hi. I’m creating a game that includes triggering audio when the player collides with a certain map, but unity gave me an error saying “ArgumentNullException: Value cannot be null”. Two things. Well, one I’ve got no clue what this even means, and two how do I fix it? It tells me that it’s on line 12. Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapArea : MonoBehaviour
{
[SerializeField] List<Tricimal> untamedTricimals;
[SerializeField] AudioSource townClip;
public void PlayAudioClip()
{
townClip.Play();
}
public Tricimal GetRandomWildTricimal()
{
var untamedTricimal = untamedTricimals[Random.Range(0, untamedTricimals.Count)];
untamedTricimal.Init();
return untamedTricimal;
}
}