I have two “wood sign” gameobjects, they both have a script called “Dialogue trigger” , however, they both have the same condition to trigger another function (see it in Update funtion). How do I make two GameObjects have separate condition via 2 same scripts (if possible)? (So when I am near sign1 game will show me text1 and if I am near sign2 game will show me text2) Or just how do I do it because theres 100% a better solution :/.
This is my dialogue trigger script:
public class DialogueTrigger : MonoBehaviour
{
public Transform InteractionSpotTransform;
public LayerMask SignLayer;
public DialogueManager DialogueManager;
public Dialogue dialogue;
private void Update()
{
if (Physics2D.OverlapCircle(InteractionSpotTransform.position, 1, SignLayer) && Input.GetKeyDown(KeyCode.Space) && !DialogueManager.InCorversation)
{
TriggerDialogue();
}
}
public void TriggerDialogue()
{
FindObjectOfType<DialogueManager>().StartDialogue(dialogue);
}
}