예제 #1
0
    private void OnTriggerExit(Collider collider)
    {
        Debug.Log("trigger");
        interactivity collidedItem = collider.GetComponent <interactivity>();

        if (collidedItem)
        {
            objectsHoveringOver.Remove(collidedItem);
        }
        //        pickup = null;
    }
예제 #2
0
    private void OnTriggerEnter(Collider collider)
    {
        Debug.Log("trigger entered");
        interactivity collidedItem = collider.GetComponent <interactivity>();

        if (collidedItem)
        {
            objectsHoveringOver.Add(collidedItem);
        }
        //        pickup = collider.gameObject;
    }
 => WaitForMessageOrReactionAsync(interactivity, message, user, null, reactions);
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (controller == null)
        {
            Debug.Log("Always have a backup plan.");
            return;
        }

        //gripButtonDown = controller.GetPressDown(gripButton);
        //gripButtonUp = controller.GetPressUp(gripButton);
        //gripButtonPressed = controller.GetPress(gripButton);

        //triggerButtonDown = controller.GetPressDown(triggerButton);
        //triggerButtonUp = controller.GetPressUp(triggerButton);
        //triggerButtonPressed = controller.GetPress(triggerButton);
        if (controller.GetPressUp(appMenu))
        {
            interactIt.plusplus();
        }

        if (controller.GetPressUp(gripButton))
        {
            interactIt.minusminus();
        }


        if (controller.GetPressDown(gripButton))
        {
            Debug.Log("click");
            float minDistance = float.MaxValue;
            controller.TriggerHapticPulse((ushort)Mathf.Lerp(0, 3999, 100));
            float distance;
            foreach (interactivity item in objectsHoveringOver)
            {
                distance = (item.transform.position - transform.position).sqrMagnitude;
                if (distance < minDistance)
                {
                    minDistance = distance;
                    closestItem = item;
                }
            }

            interactingItem = closestItem;

            if (interactingItem)
            {
                if (interactingItem.IsInteracting())
                {
                    interactingItem.EndInteraction(this);
                }
                interactingItem.BeginInteraction(this);
            }

            //           pickup.transform.parent = this.transform;
            //           pickup.GetComponent<Rigidbody>().useGravity = false;
        }

        if (controller.GetPressUp(gripButton) && interactingItem != null)
        {
            Debug.Log("C\'mon, press it.");
            interactingItem.EndInteraction(this);

            //           pickup.transofrm.parent = null;
            //          pickup.GetComponent<Rigidbody>().isKinematic = true;
        }

        //        if (controller.GetPressDown(triggerButton))
        //        {
        //            Debug.Log("oh yea");
        //        }
        //
        //        if (controller.GetPressUp(triggerButton))
        //        {
        //            Debug.Log("C\'mon, pull it.");
        //        }
    }