I have a really simple question, where I can't understand what I am missing. I am getting error:
NullReferenceException: Object reference not set to an instance of an object test.Update () (at Assets/Scripts/test.cs:13)
So, I have one class "DissableInput", where there is a simple trigger that changes whenever it triggered by another object. It returns true/false, whenever it changes.
Another class has is named "test", which basically should print out when it's true/false depending on trigger input.
//Test Class
public bool touchedCollision;
// Update is called once per frame
void Update()
{
if (this.GetComponent<DissableInput>().touchedCollision)
{
Debug.Log("IN COLL");
}
if(!this.GetComponent<DissableInput>().touchedCollision)
{
Debug.Log("NOT IN COLL");
}
}
// DisableInput Class
public bool touchedCollision;
void OnTriggerEnter (Collider other)
{
Debug.Log("In Triger");
touchedCollision = true;
}
public void OnTriggerExit(Collider other)
{
Debug.Log("Out Triger");
touchedCollision = false;
}
I am expecting that true/false will go into the test class, but instead it gives NullReferenceException error.