using System.Collections;
using System.Collections.Generic;
using UnityEngine;

class MessageTrigger : MonoBehaviour
{
    public float Distance = 1.0f;
    public string Message = "";
    public float TextWidth = 100.0f;
    public float TextDuration = 3.0f;

    private bool triggered = false; 

    public void FixedUpdate()
    {
        if(Player.Instance != null)
        {
            if((this.transform.position - Player.Instance.transform.position).magnitude < Distance)
            {
                if(!triggered)
                {
                    UserInterface.Instance.DisplayMessage(Message, TextWidth, TextDuration);
                    triggered = true;
                }
            }
            else
            {
                triggered = false; 
            }
        }
    }

}
