I am trying to create a score marker for my space shooter game. I ran into this error I have seen before, but I still don’t know how to fix it. Can someone help me?
The error is,
“Assets/Scripts/DestroyByContact.cs(7,17): error CS0246: The type or namespace name `GameController’ could not be found. Are you missing a using directive or an assembly reference?”
Here is my code
using UnityEngine;
using System.Collections;
public class DestroyByContact : MonoBehaviour
{
public int scoreValue;
private GameController gameController; //The error shows up here.
void Start ()
{
GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
if (gameControllerObject != null)
{
gameController = gameControllerObject.GetComponent <GameController>();
}
if (gameController == null)
{
Debug.Log ("Cannot find 'GameController' script");
}
}
void OnTriggerEnter2D (Collider2D other)
{
if (other.tag == "Boundary")
{
return;
}
Destroy (other.gameObject);
Destroy(transform.gameObject);
gameController.AddScore (scoreValue);
Destroy(other.gameObject);
Destroy(gameObject);
}
}
Thank you for the help!