Ejemplo n.º 1
0
 private void Update()
 {
     if (Input.GetButtonDown("Interact") && currInter)
     {
         ConditionSender sender = currInter.GetComponent <ConditionSender>();
         if (sender != null)
         {
             sender.Act();
         }
         currInter.Act();
     }
 }
Ejemplo n.º 2
0
    void UpdateRaycast()
    {
        hoverCollider = null;

        crosshair.SetActive(false);

        RaycastHit hit;

        Physics.Raycast(raycastFrom.position, raycastFrom.forward, out hit, raycastDistance);



        if (!hit.collider)
        {
            return;
        }

        hoverCollider = hit.collider;

        // interactable

        Interactable interactable = hit.collider.GetComponent <Interactable>();

        if (interactable)
        {
            if (NInput.GetMouseButtonDown(1))
            {
                if (isServer)
                {
                    interactable.Act();
                }
                else
                {
                    CmdInteract(interactable.gameObject);
                }
            }
        }

        if (interactable is Item)
        {
            if (NInput.GetMouseButtonDown(1))
            {
                Item item = interactable as Item;
                Take(item);
            }
        }

        if (interactable)
        {
            crosshair.SetActive(true);
        }
    }