void OnTriggerEnter(Collider other) { if (active & other.tag == "Player") { GrabKey gc = other.gameObject.GetComponent <GrabKey>(); NotificationScreen.getInstance().displayNotification("Obtained key to cage!", Time.time, 3); AudioManager.getInstance().playObtained(); ScoreSystem.getInstance().addToScore(50, ScoreSystem.scType.NONE); gc.giveKey(); active = false; } }
void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "Player" && doorController.IsDoorClosed) // this string is your newly created tag { GrabKey gc = collider.gameObject.GetComponent <GrabKey>(); if (gc.nKeys > 0) { print("Opening the door"); doorController.OpenDoor(); gc.nKeys--; } else { NotificationScreen.getInstance().displayNotification("You must find the key to the cage!", Time.time, 3); print("Can't open the door"); } } }