Exemplo n.º 1
0
    //Raycasting
    void FixedUpdate()
    {
        RaycastHit hit;
        Vector3    direction = playerGraphics.TransformDirection(Vector3.forward);

        if (Physics.Raycast(transform.position, direction, out hit, interactableDistance))
        {
            Transform interactInfo = hit.collider.transform.Find("InteractInfo");
            if (interactInfo != null && LayerMask.LayerToName(interactInfo.gameObject.layer).Equals(interactableLayerName))
            {
                interactNPC = hit.collider.transform.Find("InteractInfo").GetComponent <InteractNPC>();
                if (interactNPC != null)
                {
                    interactNPC.ReceivePlayerInteraction();
                }
            }
        }
        else
        {
            //Nothing hit
            if (interactNPC != null)
            {
                interactNPC.SetSelected(false);
                interactNPC = null;
            }
        }
    }
Exemplo n.º 2
0
 //Called when we have pressed "Jump" in PlayerController
 public void ActivateInteract()
 {
     if (interactNPC != null)
     {
         playerController.SetBlocked(true);
         if (!interactNPC.ActivateInteract())
         {
             //Dialog ended
             playerController.SetBlocked(false);
             interactNPC = null;
         }
     }
 }