Exemple #1
0
 void Update()
 {
     for (int i = 0; i < points.Length; i++)
     {
         if ((leverTransform.position - worldPoints[i]).magnitude <= activateDistance)
         {
             if (current != interactibles[i])
             {
                 if (!leverHoldable.IsGrabbed)
                 {
                     SnapToPosition(worldPoints[i]);
                 }
                 current = interactibles[i];
                 current.InteractStart();
             }
         }
         else
         {
             if (current == interactibles[i])
             {
                 current.InteractEnd();
                 current = null;
             }
         }
     }
 }
Exemple #2
0
    void Update()
    {
        if (Application.isEditor && Input.GetKeyDown(interactButton) || OVRInput.GetDown(interactButtonVR, hand))
        {
            interactible = GetBestInteractible();
            if (interactible != null)
            {
                interactible.InteractStart();
            }
        }

        if (Application.isEditor && Input.GetKeyUp(interactButton) || OVRInput.GetUp(interactButtonVR, hand))
        {
            if (interactible != null)
            {
                interactible.InteractEnd();
                interactible = null;
            }
        }
    }
Exemple #3
0
    void Update()
    {
        if (beingPressed)
        {
            transform.position = Vector3.MoveTowards(transform.position, pressedPosition, pressSpeed);
        }
        else
        {
            transform.position = Vector3.MoveTowards(transform.position, unpressedPosition, pressSpeed);
        }

        if (!pressedDown && (transform.position - pressedPosition).magnitude < 0.01)
        {
            pressedDown = true;
            connectedInteractible.InteractStart();
        }

        if (pressedDown && (transform.position - unpressedPosition).magnitude < 0.01)
        {
            pressedDown = false;
            connectedInteractible.InteractEnd();
        }
    }