private void Interact() { if (Input.GetKeyDown(KeyCode.Space)) { RaycastHit2D hit = Physics2D.Raycast(rigidbody.position, lookDirection, 1.5f, LayerMask.GetMask("NPC")); if (hit.collider != null) { if (hit.transform.gameObject.tag == "NPC") { npc = hit.collider.GetComponent <Npcdialog>(); npc.MessageHandler(); } else if (hit.transform.gameObject.tag == "Altar") { Altar altar = hit.collider.GetComponent <Altar>(); altar.HandleInteraction(); } else if (hit.transform.gameObject.tag == "PuzzleDoor") { hit.transform.gameObject.GetComponent <PassPuzzle>().OpenPuzzle(); } } else if (dialogHandler.messageReceived) { dialogHandler.NextSentence(); } else { return; } } }