Hey guys,
I have a script called CoinPickupNew where it is set that a char picked up a key:
gotkey = true;
I have created a trigger empty game object that while the char has a key and when passed through a door will open:
using UnityEngine;
using System.Collections;
public class OpenDoor : MonoBehaviour {
public GameObject door;
void OnTriggerEnter2D(Collider2D col)
{
if (GetComponent<CoinPickupNew>().gotkey == true)
{
door.SetActive(false);
}
}
}
I drag the door sprite to the Door slot but still receive a Object reference (col) not set to an instance of an object error, while passing through trigger object.