I get this error when trying to reference a variable from another script.
NullReferenceException: Object reference not set to an instance of an object
UIManager.Start () (at Assets/Scripts/UIManager.cs:16)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(CharacterStats))]
public class UIManager : MonoBehaviour {
public Text health;
public Text armor;
private int currentHealth;
// Use this for initialization
void Start () {
GetComponent<CharacterStats>().currentHealth += currentHealth;
}
// Update is called once per frame
void Update () {
health.text = currentHealth.ToString();
}
}