Exemple #1
0
    // Update is called once per frame
    void LateUpdate()
    {
        triggerUp = false;

        if (RightHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool val) && val)
        {
            // if start pressing, trigger event
            if (!IsPressed)
            {
                IsPressed = true;
                Debug.Log("Trig down now");
            }
        }
        else if (IsPressed) // check for button release
        {
            IsPressed = false;
            triggerUp = true;
        }
        // Above code should work for OnTriggerUp (this means clean-up is required on current onTriggerUp method)

        if (ExperimentController.Instance().CurrentTask == null)
        {
            return;
        }

        Vector3 realHandPosition = GetHandPosition();

        // Update the position of the cursor depending on which hand is involved
        transform.position = ConvertPosition(realHandPosition);

        if ((previousPosition - realHandPosition).magnitude > 0.001f)
        {
            PauseTime = 0f;
        }
        else
        {
            PauseTime += Time.deltaTime;
        }

        previousPosition = realHandPosition;

        if (ExperimentController.Instance().CurrentTask.Home != null)
        {
            DistanceFromHome =
                (transform.position - ExperimentController.Instance().CurrentTask.Home.transform.position).magnitude;
        }
        else
        {
            DistanceFromHome = -1f;
        }

        prevLeftTrigger  = IsTriggerDown("l");
        prevRightTrigger = IsTriggerDown("r");
    }
Exemple #2
0
 public bool OnTriggerUp(String hand)
 {
     if (hand == "l")
     {
         return(LeftHandDevice == null
             ? false
             : !LeftHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool val) && prevLeftTrigger);
     }
     else
     {
         return(RightHandDevice == null
             ? false
             : !RightHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool val) && prevRightTrigger);
     }
 }
Exemple #3
0
 public Vector3 GetVelocity(String hand)
 {
     if (hand == "l")
     {
         Vector3 vel;
         LeftHandDevice.TryGetFeatureValue(CommonUsages.deviceVelocity, out vel);
         return(vel);
     }
     else
     {
         Vector3 vel;
         RightHandDevice.TryGetFeatureValue(CommonUsages.deviceVelocity, out vel);
         return(vel);
     }
 }
Exemple #4
0
 public bool IsTriggerDown(String hand)
 {
     if (hand == "l")
     {
         return(LeftHandDevice == null
             ? false
             : LeftHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool val) && val);
     }
     else
     {
         return(RightHandDevice == null
             ? false
             : RightHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool val) && val);
         // THE ABOVE CODE WORKS!
     }
 }