I’m trying to access a variable in other script but it only gives me:
NullReferenceException: Object reference not set to an instance of an object
I’m trying to access ‘sanity’ variable from my slenderAI script.
I’m trying to access them with this code:
using UnityEngine;
using System.Collections;
public class StaticScreen : MonoBehaviour {
public slenderAI script;
void Start(){
script = GetComponent<slenderAI>();
}
void Update(){
if(script.sanity < 100){
Debug.Log("Hi");
}
}
}