Пример #1
0
    public void CheckHit()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity))
        {
            //Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);
            if (hit.distance < Reach)
            {
                currentItem = hit.transform.gameObject;
                if (currentItem.layer == itemlayer)
                {
                    if (currentItem.GetComponent <Item>() != null)
                    {
                        HUD.OpenMessagePanel(currentItem.GetComponent <Item>().itemName);
                    }
                    CheckInput(currentItem);
                }
                else if (currentItem.tag == backpackTag)
                {
                    HUD.OpenMessagePanel("backpack");
                    CheckInput(currentItem);
                }
                else if (currentItem.GetComponent <Item>() == null && currentItem.tag == interactiveObjectTag)
                {
                    HUD.OpenInteractMessagePanel(currentItem.name);
                    CheckInput(currentItem);
                }
                else if (currentItem.GetComponent <Item>() == null && currentItem.tag != backpackTag)
                {
                    HUD.CloseMessagePanel();
                }
            }
            else
            {
                HUD.CloseMessagePanel();
            }
        }
    }