Exemplo n.º 1
0
    void Update()
    {
        FindClosestObject();

        if (closestObject != null)
        {
            if (InRange() && Input.GetKeyDown(pickUpKey))
            {
                int currentLayer = closestObject.layer;

                if (currentLayer == LayerMask.NameToLayer(interactableLayerName))
                {
                    closestObject.GetComponent <ActivationManager>().Activate(transform);
                }
                else if (currentLayer == LayerMask.NameToLayer(pickUpLayerName))
                {
                    PickUp pickUp      = closestObject.GetComponent <PickUp>();
                    string name        = pickUp.GetItemName();
                    string discription = pickUp.GetItemDiscription();
                    pI.AddToInventory(name, discription);

                    closestObject.SetActive(false);

                    closestObject.layer = 0;
                }
                else if (currentLayer == LayerMask.NameToLayer(lookLayerName))
                {
                }

                closestObject = null;
            }
        }
    }