]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Dialogue/DialogueTrigger.cs
Dialog-System v0.3
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Dialogue / DialogueTrigger.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4
5 public class DialogueTrigger : MonoBehaviour
6 {
7     [SerializeField]
8     GameObject DialogueManager;
9
10     Dialogue dialogue;
11
12     void Start()
13     {
14         dialogue = DialogueManager.GetComponent<Dialogue>();
15     }
16
17     private void OnTriggerEnter2D(Collider2D collision)
18     {
19         if(collision.gameObject.CompareTag("Player"))
20         {
21             StartCoroutine(dialogue.Type());
22             collision.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
23             GetComponent<BoxCollider2D>().enabled = false;
24         }
25     }
26 }