I’m trying to instantiate a prefab object that has a Audio Source in, because an error, I deleted the prefab and made it again, but now I have another error that says:
“MissingReferenceException: The variable Logro1 of Montañita1 doesn’t exist anymore. You probably need to reassign the Logro1 variable of the ‘Montañita1’ script in the inspector.”
When I step over the collider it works, I can listen the audio but the error is there, and it creates a clone that even if I put “destroy”, it still here.
The code is:
public class Montañita1 : MonoBehaviour
{
public GameObject Logro1;
public Text myText;
void OnTriggerEnter2D (Collider2D other)
{
StartCoroutine ("Logro");
}
IEnumerator Logro ()
{
Instantiate(Logro1);
myText.text = ("Encontraste tu primer fósil! Muy bien!");
yield return new WaitForSeconds (4);
Destroy(myText);
Destroy(gameObject);
}
}