void OnTriggerExit2D(Collider2D myExit) //when player exits the boor's collider, sets the boolean to false { if (myExit.gameObject.tag == "Door") { //Debug.Log("exit = true"); touchingDoor = false; touchingLockedDoor = false; } if (myExit.gameObject.tag == "MessagePickUp") { Debug.Log("exit = true"); pressE.SetActive(false); checkMessage = false; } if (myExit.gameObject.tag == "Switch") { swtch = myExit.GetComponent <doorSwitch>(); swtch.plyrInLine = false; pressE.SetActive(false); Debug.Log("gone from switch"); } if (myExit.gameObject.tag == "Breakable") { if (GM.gotHammer == true) { nearBreakableWall = false; BreakableWall = null; pressE.SetActive(false); } } }
void OnTriggerEnter2D(Collider2D myColl) { if (myColl.gameObject.CompareTag("Door")) //If player is in front of door { //Debug.Log("In Front of Door"); door = myColl.GetComponent <DoorController>(); if (door.locked == false) { //Debug.Log("unlocked"); touchingDoor = true; } else if (door.locked == true) { touchingLockedDoor = true; } } if (myColl.gameObject.tag == "Breakable") { if (GM.gotHammer == true) { nearBreakableWall = true; pressE.SetActive(true); BreakableWall = myColl.gameObject; } } if (myColl.gameObject.CompareTag("MessagePickUp")) { Mes = myColl.GetComponent <MessageController>(); checkMessage = true; pressE.SetActive(true); } if (myColl.CompareTag("Key1")) { GM.gotkey1 = true; } if (myColl.CompareTag("Key2")) { GM.gotkey2 = true; } if (myColl.CompareTag("Key3")) { GM.gotkey3 = true; } if (myColl.CompareTag("MapPickup")) { GM.gotMap = true; Destroy(myColl); } if (myColl.CompareTag("Switch")) { swtch = myColl.GetComponent <doorSwitch>(); swtch.plyrInLine = true; Debug.Log("front of switch"); pressE.SetActive(true); } if (myColl.CompareTag("flashlight")) { GM.gotLight = true; } //if (myColl.gameObject.tag != "Door") //{ // touchingDoor = false; //} }