How to show dialogue when triggered by collision with npc collide box?
Hello guys, im a newbie that have started making 2d game with unity, in which i confused on how i must do to make a dialogue show when i collide with the npc.. at first i thought i will first hide the panel text and setitactive whenever player collide, but i face another prolem cause i dont know what to do if i collide with another npc with another dialogue and how to make a script to automatically choose which panel/dialogue to show up based on npc i collide with
using UnityEngine;
public class PlayerInteract : MonoBehaviour {
GameObject dialogue;
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("InterObject"))
{
dialogue.SetActive(true);
}
}
// Update is called once per frame
void Update () {
}
}
more or less like this
is there any better way to trigger dialogue or solution for this? thank you very much
Your answer
![](https://koobas.hobune.stream/wayback/20220612185413im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
NavMesh Agent Navigating Instantiated Environment? 0 Answers
NPC Dialog 1 Answer
how to load panels in a platformer game? 0 Answers
How can i make an Dialogue for an NPC 0 Answers