Hi. Quick question. I have an object in my scene called “Enemy” and I want to test it for null every frame, so when it is destroyed, the scene will reset. This is the script I’ve got:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Example : MonoBehaviour {
public GameObject Enemy;
// Use this for initialization
void Start () {
if(Enemy == null)
{
Reset();
}
}
// Update is called once per frame
void Update () {
}
void Reset()
{
// The reset function will Reset the game by reloading the same level
SceneManager.LoadScene(1);
}
}
I know I’m doing something wrong with “importing” the object in the script, but I’m new to Unity and don’t know how.
Thank you!