예제 #1
0
    private void Update()
    {
        //Drawing laser and picking up object
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, 100))
        {
            _hitPoint = hit.point;
            ShowLaser(hit);
            if ((LeftController.GetHairTriggerDown() || RightController.GetHairTriggerDown()) && !heldGameObject && hit.collider.gameObject.GetComponent <Rigidbody>())
            {
                if (applicationController.currentCube == hit.collider.gameObject)
                {
                    applicationController.LogCorrectObject(-1.0f);
                }
                else
                {
                    applicationController.LogWrongObject(-1.0f);
                }
                GrabObject(hit.collider.gameObject);
            }
            else if ((LeftController.GetHairTriggerDown() || RightController.GetHairTriggerDown()) && !heldGameObject)
            {
                applicationController.LogMissedObject(-1.0f);
            }
        }

        //Releasing an object
        if ((LeftController.GetHairTriggerUp() || RightController.GetHairTriggerUp()) && heldGameObject)
        {
            applicationController.LogDroppedObject();
            ReleaseObject();
        }
        else if (heldGameObject && !GetComponent <FixedJoint>())
        {
            FixedJoint joint = AddFixedJoint();
            joint.connectedBody = heldGameObject.GetComponent <Rigidbody>();
        }
    }
예제 #2
0
        //EMPTY
        #region PUBLIC_METHODS
        #endregion PUBLIC_METHODS

        #region PRIVATE_METHODS
        /// <summary>
        /// Handle the Left Controller input and put them in the Events
        /// </summary>
        void CheckLeftControllerInput()
        {
            BoolVariable temp;

            #region TRIGGER
            temp = LeftVariablesDictionnary.Get("TriggerIsDown");

            if (!temp.Value && LeftController.GetHairTriggerDown())
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetHairTriggerUp())
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftTriggerUp");
                _leftEvent.Raise();
            }
            #endregion TRIGGER

            #region TOUCHPAD
            temp = LeftVariablesDictionnary.Get("ThumbIsDown");

            LeftThumbOrientation.SetValue(LeftController.GetAxis());

            if (LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftThumbUp");
                _leftEvent.Raise();
            }

            if (LeftController.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching");
                _leftEventBool.Raise(true);
            }
            else if (LeftController.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                _leftEventBool = (GameEventBool)LeftEventsDictionnary.Get("LeftThumbTouching");
                _leftEventBool.Raise(false);
            }
            #endregion TOUCHPAD

            #region GRIP
            temp = LeftVariablesDictionnary.Get("GripIsDown");

            if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftGripUp");
                _leftEvent.Raise();
            }
            #endregion GRIP

            #region MENU
            temp = LeftVariablesDictionnary.Get("MenuIsDown");

            if (!temp.Value && LeftController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                temp.SetValue(true);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuDown");
                _leftEvent.Raise();
            }
            else if (temp.Value && LeftController.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                temp.SetValue(false);
                _leftEvent = (GameEvent)LeftEventsDictionnary.Get("LeftMenuUp");
                _leftEvent.Raise();
            }
            #endregion MENU
        }