Here is the code:
using UnityEngine;
using System.Collections;
public class PunteggioByContact : MonoBehaviour
{
public GameObject explosion;
public GameObject playerExplosion;
public int scoreValue;
private GameController CarPunteggio;
void Start ()
{
GameObject CarPunteggioObject = GameObject.FindWithTag ("GameController");
if (CarPunteggioObject != null)
{
CarPunteggio = CarPunteggioObject.GetComponent <CarPunteggio>();
}
if (CarPunteggio == null)
{
Debug.Log ("Cannot find 'GameController' script");
}
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Boundary")
{
return;
}
Instantiate(explosion, transform.position, transform.rotation);
if (other.tag == "Player")
{
CarPunteggio.AddScore (scoreValue);
}
Destroy(other.gameObject);
Destroy(gameObject);
}
}
I cotinue to get this error, and I don’t know why:
Assets/Scripts/PunteggioByContact.cs(16,25): error CS0029: Cannot implicitly convert type `CarPunteggio' to `GameController'