GetRightHandEvent() public méthode

public GetRightHandEvent ( ) : HandEventType
Résultat HandEventType
 void Update()
 {
     if (manager != null && manager.IsInteractionInited())
     {
         // check for left hand grip
         if (manager.GetLeftHandEvent() == InteractionWrapper.InteractionHandEventType.Grip)
         {
             isLeftHandGripped  = true;
             isLeftHandReleased = false;
             //Debug.Log ("Left Hand Gripped");
             GameObject.Find("LeftHand").animation.Play("LeftHandGrip");
         }
         else if (manager.GetLeftHandEvent() == InteractionWrapper.InteractionHandEventType.Release)
         {
             isLeftHandGripped  = false;
             isLeftHandReleased = true;
             //Debug.Log ("Left Hand Released");
             GameObject.Find("LeftHand").animation.Play("LeftHandRelease");
         }
         //check for right hand grip
         if (manager.GetRightHandEvent() == InteractionWrapper.InteractionHandEventType.Grip)
         {
             isRightHandGripped  = true;
             isRightHandReleased = false;
             //Debug.Log ("Right Hand Gripped");
             GameObject.Find("RightHand").animation.Play("RightHandGrip");
         }
         else if (manager.GetRightHandEvent() == InteractionWrapper.InteractionHandEventType.Release)
         {
             isRightHandGripped  = false;
             isRightHandReleased = true;
             //Debug.Log ("Right Hand Released");
             GameObject.Find("RightHand").animation.Play("RightHandRelease");
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        if (interactionManager != null && interactionManager.IsInteractionInited() && manager.IsUserDetected(0))
        {
            right_cube.position = ScreenToPixel(interactionManager.GetRightHandScreenPos()) / 100;

            left_cube.position = ScreenToPixel(interactionManager.GetLeftHandScreenPos()) / 100;

            RightHandEvent = interactionManager.GetRightHandEvent();
            LeftHandEvent  = interactionManager.GetLeftHandEvent();

            RightHand_pos = interactionManager.GetRightHandScreenPos();
            LeftHand_pos  = interactionManager.GetLeftHandScreenPos();

            if (RightHandEvent != InteractionManager.HandEventType.Grip && RightHandEvent != InteractionManager.HandEventType.None)
            {
                RightHandGrip_pos        = interactionManager.GetRightHandScreenPos();
                RightHandVerticalEvent   = HandGripVerticalType.None;
                RightHandHorizontalEvent = HandGripHorizontalType.None;
            }
            else
            {
                if (RightHand_pos.x < RightHandGrip_pos.x && Mathf.Abs(RightHand_pos.x - RightHandGrip_pos.x) > 0.1f)
                {
                    RightHandHorizontalEvent = HandGripHorizontalType.Left;
                }
                else if (RightHand_pos.x > RightHandGrip_pos.x && Mathf.Abs(RightHand_pos.x - RightHandGrip_pos.x) > 0.1f)
                {
                    RightHandHorizontalEvent = HandGripHorizontalType.Right;
                }
                else if (Mathf.Abs(RightHand_pos.x - RightHandGrip_pos.x) < 0.1f)
                {
                    RightHandHorizontalEvent = HandGripHorizontalType.None;
                }

                if (RightHand_pos.y > RightHandGrip_pos.y && Mathf.Abs(RightHand_pos.y - RightHandGrip_pos.y) > 0.1f)
                {
                    RightHandVerticalEvent = HandGripVerticalType.Up;
                }
                else if (RightHand_pos.y < RightHandGrip_pos.y && Mathf.Abs(RightHand_pos.y - RightHandGrip_pos.y) > 0.1f)
                {
                    RightHandVerticalEvent = HandGripVerticalType.Down;
                }
                else if (Mathf.Abs(RightHand_pos.y - RightHandGrip_pos.y) < 0.1f)
                {
                    RightHandVerticalEvent = HandGripVerticalType.None;
                }
            }


            if (LeftHandEvent != InteractionManager.HandEventType.Grip && LeftHandEvent != InteractionManager.HandEventType.None)
            {
                LeftHandGrip_pos        = interactionManager.GetLeftHandScreenPos();
                LeftHandHorizontalEvent = HandGripHorizontalType.None;
                LeftHandVerticalEvent   = HandGripVerticalType.None;
            }
            else
            {
                if (LeftHand_pos.x < LeftHandGrip_pos.x && Mathf.Abs(LeftHand_pos.x - LeftHandGrip_pos.x) > 0.1f)
                {
                    LeftHandHorizontalEvent = HandGripHorizontalType.Left;
                }
                else if (LeftHand_pos.x > LeftHandGrip_pos.x && Mathf.Abs(LeftHand_pos.x - LeftHandGrip_pos.x) > 0.1f)
                {
                    LeftHandHorizontalEvent = HandGripHorizontalType.Right;
                }
                else if (Mathf.Abs(LeftHand_pos.x - LeftHandGrip_pos.x) < 0.1f)
                {
                    LeftHandHorizontalEvent = HandGripHorizontalType.None;
                }

                if (LeftHand_pos.y > LeftHandGrip_pos.y && Mathf.Abs(LeftHand_pos.y - LeftHandGrip_pos.y) > 0.1f)
                {
                    LeftHandVerticalEvent = HandGripVerticalType.Up;
                }
                else if (LeftHand_pos.y < LeftHandGrip_pos.y && Mathf.Abs(LeftHand_pos.y - LeftHandGrip_pos.y) > 0.1f)
                {
                    LeftHandVerticalEvent = HandGripVerticalType.Down;
                }
                else if (Mathf.Abs(LeftHand_pos.y - LeftHandGrip_pos.y) < 0.1f)
                {
                    LeftHandVerticalEvent = HandGripVerticalType.None;
                }
            }

            if (LeftHandEvent == InteractionManager.HandEventType.Grip && RightHandEvent == InteractionManager.HandEventType.Grip && RightHandVerticalEvent == HandGripVerticalType.None && RightHandHorizontalEvent == HandGripHorizontalType.None && LeftHandHorizontalEvent == HandGripHorizontalType.None && LeftHandVerticalEvent == HandGripVerticalType.None)
            {
                t += Time.deltaTime;

                if (t > 2)
                {
                    handHover = true;
                }
            }
            else
            {
                handHover = false;
                t         = 0;
            }

            if (LeftHandEvent == InteractionManager.HandEventType.Release && RightHandEvent == InteractionManager.HandEventType.Release && game_ctr.UISTATE != GameCtr.UIState.Close)
            {
                s += Time.deltaTime;
                c += Time.deltaTime;

                if (s > 6)
                {
                    if (!standby)
                    {
                        standby = true;
                        s       = 0;
                    }
                    else
                    {
                        standby = false;
                        s       = 0;
                    }
                }

                if (c > 10)
                {
                    c     = 0;
                    s     = 0;
                    close = true;
                }
                else
                {
                    close = false;
                }
            }
            else
            {
                //standby = false;
                s     = 0;
                c     = 0;
                close = false;
            }


            //Debug.Log("Left:" + LeftHandEvent + "  "+ LeftHandHorizontalEvent + "   " + LeftHandVerticalEvent);
        }
    }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        if (handsmanage == null)
        {
            handsmanage = InteractionManager.Instance;
        }
        //		if (Vector3.Distance (target.transform.position, ballllll.transform.position) < 0.1f) {
        //			//StartCoroutine (Drop ());
        //			score++;
        //			SuccessClip.Play ();
        //			countText.text = "Score: " + score.ToString();
        //			PlayerPrefs.SetString(PlayerPrefs.GetInt("GAMENUM").ToString() + "\t" + "handLocationData" + "\t" + score.ToString(), right_hand_trans.handLocationData);
        //			Debug.Log(PlayerPrefs.GetInt("GAMENUM").ToString() + "\t" + right_hand_trans.handLocationData + "\t" + score.ToString());
        //			//This following resets the position of the ball and makes everything to back to defualt.
        //
        //			right_hand_trans.isTouchingBall = false;
        //			right_hand_trans.ball.SetActive (false);
        //			right_hand_trans.ball.transform.position = initballpos;
        //			right_hand_trans.ball.SetActive (true);
        //			right_hand_trans.ball.transform.parent = null;
        //		}

        if (Mathf.Abs(transform.position.x - target.transform.position.x) < .1f && Mathf.Abs(transform.position.y - target.transform.position.y) < .1f)
        {
            if (Mathf.Abs(transform.position.z - target.transform.position.z) < .1f)
            {
                ballllll.transform.parent = null;
                ballllll.SetActive(false);
                ballllll.transform.position = initballpos;
                ballllll.SetActive(true);
                score++;
                countText.text = "Score: " + score.ToString();
                SuccessClip.Play();
                pScore++;
            }
        }

        // Level 2
        //		if (pScore == 3) {
        //do something
        //		}

        // Simple conditional statement that will drop the ball (game object) when:
        // 1) The Interaction Manager senses that there is a release gesture.
        // Also, this will enable gravity on and physics off so the ball falls straight down from the hand.
        if (handsmanage.GetLastRightHandEvent() == InteractionManager.HandEventType.Release)
        {
            transform.parent = null;
            rb.isKinematic   = false;
            rb.useGravity    = true;
            isTouchingBall   = false;
        }

        // Simple conditional statement that will pick up the ball (game object) if:
        // 1) The Interaction Manager senses that there is a grip gesture.
        // 2) The distance between the avatar's hand and ball is less than .1f away from another.
        if ((handsmanage.GetRightHandEvent() == InteractionManager.HandEventType.Grip) &&
            (Vector3.Distance(handdddd.transform.position, ballllll.transform.position) < .15f))
        {
            ballllll.transform.parent = handdddd.transform;
            isTouchingBall            = true;
            rb.isKinematic            = true;
        }

        // Simple conditional statement that will begin to record data when true.
        // This will only be true while the grip gesture and within distance of ball is true.
        if (isTouchingBall)
        {
            handLocationData += handdddd.transform.position;
        }
    }