Загрузка данных


using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class Interactable : MonoBehaviour
{
    public GameObject title;
    public Transform grabPoint;
    private float maxLength = 5;
    private GameObject player;
    public bool isGrabbable = false;

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
    }

    void OnMouseEnter()
    {
        float length = (transform.position - player.transform.position).magnitude;
        if (length <= maxLength)
        {
            title.SetActive(true);
        }
    }

    void OnMouseOver()
    {
        float length = (transform.position - player.transform.position).magnitude;
        if (length > maxLength)
        {
            title.SetActive(false);
        }
    }

    void OnMouseExit()
    {
        title.SetActive(false);
    }
}