Ok so i asked a question yesterday regarding why my final score wasn't displaying correctly but well I've now got a weird error to do with it. basically I'm using a c# level editor to create my levels and the endpoint when spawned as a prefab just doesn't like the code I've used. My code works fine when I have the object in the scene hierarchy but this is the current error I'm now getting and I would love some help. thank you very much for any help. all code and picture of error below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EndBlock : MonoBehaviour
{
private string endblock = "player";
private GameObject fScreen;
public bool gameEnd = false;
void Start()
{
fScreen = GameObject.Find ("EndCardScreen") as GameObject;
fScreen.gameObject.SetActive (false);
Debug.Log("Found endcardscreen");
}
private void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == endblock)
{
fScreen.gameObject.SetActive (true);
gameEnd = true;
Debug.Log("Displaying endcardscreen");
Debug.Log ("You Win");
}
}
}
![alt text][1]
[1]: /storage/temp/122545-unityerror.png
↧