Question by
avnerpower · Dec 17, 2015 at 04:49 PM ·
getcomponentvariablesaccess
Why can't I access a variable from a different script?
I keep getting the error NullReferenceException: Object reference not set to an instance of an object Inventory.Update () (at Assets/Inventory.cs:23) Am I doing something specific wrong? What's the error? void Start() { Movement Avner = GetComponent();
if (Avner.Inventory.Contains("Google Translate")) { item1.SetActive(true); }
}`
Comment
void Start()
{
$$anonymous$$ovement Avner = GetComponent<$$anonymous$$ovement>();
if (Avner.Inventory.Contains("Google Translate")) { item1.SetActive(true); }
}
Sorry I meant to put this like this
Are you sure your gameobject has the component called "$$anonymous$$ovement" ?
It's the name of the script called $$anonymous$$ovement.
is Inventory initialized? it looks like a hashtable or dictionary remember to initialize them. is item1 set to something?