void Update() { if (isActive) { Direction currentDir = (Direction)animator.GetInteger("Direction"); Vector3 raycastDir = Vector3.zero; if (currentDir == Direction.Left) { raycastDir = Vector3.left; } else if (currentDir == Direction.Right) { raycastDir = Vector3.right; } else if (currentDir == Direction.Up) { raycastDir = Vector3.up; } else if (currentDir == Direction.Down) { raycastDir = Vector3.down; } // Raycast Vector3 raycastOrigin = new Vector3(transform.position.x + 0.5f, transform.position.y - 0.5f, transform.position.z); RaycastHit2D hit = Physics2D.Raycast(raycastOrigin, raycastDir, 1, playerLayer); // Debug.DrawRay(raycastOrigin, raycastDir, Color.green); // Ef Rasmusen er að fara að rekast á leikmann, stoppa hann og núllstilla if (hit.collider != null && hit.collider.tag == "Player") { timeline.PauseTimeline(); caughtMessageTimeline.Play(); isActive = false; } } }
public void StartDialogue(Dialogue dialogue) { // Pása tímalínu ef hún er tengd if (timelineController) { timelineController.PauseTimeline(); } // Birtir dialogue box á skjáinn animator.SetBool("IsOpen", true); nameText.text = dialogue.name; sentences.Clear(); // Setur allar setningar í queue foreach (string sentence in dialogue.sentences) { sentences.Enqueue(sentence); } DisplayNextSentence(); }