コード例 #1
0
    // FixedUpdate is not called every graphical frame but rather every physics frame
    void FixedUpdate()
    {
        if (joystick.GetAxis().x > 0.0f)
        {
            Invoke("Activate", 2.0f);
            Invoke("FreeMode", 36.0f);
        }
        else if (joystick.GetAxis().x < 0.0f)
        {
            GameObject.FindWithTag("left").GetComponent <Valve.VR.InteractionSystem.Tutorial> ().enabled  = false;
            GameObject.FindWithTag("right").GetComponent <Valve.VR.InteractionSystem.Tutorial> ().enabled = false;
        }

        if (state == SteeringState.Standing)
        {
            if (Triggerbutton.GetPressDown())
            {
                Vector3 temp = space.transform.position;
                temp.y -= 0.15f;
                space.transform.position = temp;
                state = SteeringState.Sitting;
            }
            else
            {
            }
        }

        if (state == SteeringState.Sitting)
        {
            if (sidebutton.GetPressDown())
            {
                Vector3 temp1 = space.transform.position;
                temp1.y += 0.15f;
                space.transform.position = temp1;
                state = SteeringState.Standing;
            }
            else
            {
            }
        }
    }
コード例 #2
0
        // Update is called once per frame
        void Update()
        {
            velocityl = lefthand.GetComponent <VelocityEstimator>().speed;
            velocityr = righthand.GetComponent <VelocityEstimator>().speed;

            if (triggerButton.GetPressDown())
            {
                if (!bassState)
                {
                    GameObject.FindWithTag("27").GetComponent <Renderer> ().material = Light;
                    temp1        = GameObject.FindWithTag("27").GetComponent <AudioSource> ();
                    temp1.volume = 0.3f;
                    temp1.Play();
                    bassState = true;
                    Invoke("goBack", 0.1f);
                }
            }
            if (triggerButton.GetPressUp())
            {
                bassState = false;
            }

            if (triggerButton2.GetPressDown())
            {
                if (!bassStateStrong)
                {
                    GameObject.FindWithTag("27").GetComponent <Renderer> ().material = Light;
                    temp2        = GameObject.FindWithTag("27").GetComponent <AudioSource> ();
                    temp2.volume = 1.0f;
                    temp2.Play();
                    bassStateStrong = true;
                    Invoke("goBack", 0.1f);
                }
            }
            if (triggerButton2.GetPressUp())
            {
                bassStateStrong = false;
            }
        }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        bool buttonPress = false;

        if (pauseButton.GetPressDown())
        {
            buttonPress     = true;
            pauseButtonDown = true;
        }
        if (!buttonPress && pauseButtonDown)
        {
            pauseButtonOnClick = true;
            pauseButtonDown    = false;
        }
        buttonPress = false;
        //TODO test skip+pause
        if (skipButton.GetPressDown())
        {
            buttonPress    = true;
            skipButtonDown = true;
        }
        if (!buttonPress && skipButtonDown)
        {
            skipButtonOnClick = true;
            skipButtonDown    = false;
        }
        if (pauseButtonOnClick)
        {
            //   print("click");
            pauseButtonOnClick = false;
            GameManager.instance.MenuOnClick();
        }
        else if (skipButtonOnClick)
        {
            skipButtonOnClick = false;
            GameManager.instance.TriggerOnClick();
        }
    }
コード例 #4
0
    // FixedUpdate is not called every graphical frame but rather every physics frame
    void FixedUpdate()
    {
        // If state is open
        if (state == VirtualHandState.Open)
        {
            // If the hand is touching something
            if (hand.triggerOngoing)
            {
                // Change state to touching
                Debug.Log("Touching");
                state = VirtualHandState.Touching;
            }

            // If the hand is closed
            else if (button.GetPress())
            {
                // Change state to closed
                state     = VirtualHandState.Closed;
                hand.type = AffectType.Physical;
            }
            else
            {
                // do nothing
            }
        }

        //If state is closed
        if (state == VirtualHandState.Closed)
        {
            if (!button.GetPress())
            {
                //change state to open
                state     = VirtualHandState.Open;
                hand.type = AffectType.Virtual;
            }

            else
            {
                //do nothing
            }
        }

        // If state is touching
        else if (state == VirtualHandState.Touching)
        {
            // If the hand is not touching something
            if (!hand.triggerOngoing)
            {
                // Change state to open
                state = VirtualHandState.Open;
            }

            // If the hand is touching something and the button is pressed
            else if (hand.triggerOngoing && button.GetPress())
            {
                // Fetch touched target
                Collider target = hand.ongoingTriggers[0];
                // Create a fixed joint between the hand and the target
                grasp = target.gameObject.AddComponent <FixedJoint>();
                // Set the connection
                grasp.connectedBody = hand.gameObject.GetComponent <Rigidbody>();

                // Change state to holding
                state = VirtualHandState.Holding;
            }

            else if (hand.triggerOngoing && grip.GetPressDown())
            {
                Debug.Log("Apply");
                Collider target = hand.ongoingTriggers[0];

                if (target.GetComponent <Status>())
                {
                    status = target.GetComponent <Status>().isOn;
                    if (status == true)
                    {
                        Debug.Log("TurnOff");
                        status = false;
                        target.GetComponent <Status>().isOn = status;
                    }
                    else if (status == false)
                    {
                        Debug.Log("TurnOn");
                        status = true;
                        target.GetComponent <Status>().isOn = status;
                    }
                }
                else if (target.GetComponent <GoggleScript>())
                {
                    status = target.GetComponent <GoggleScript>().isOn;
                    if (status == true)
                    {
                        Debug.Log("TurnOff");
                        status = false;
                        target.GetComponent <GoggleScript>().isOn = status;
                    }
                    else if (status == false)
                    {
                        Debug.Log("TurnOn");
                        status = true;
                        target.GetComponent <GoggleScript>().isOn = status;
                    }
                }

                state = VirtualHandState.Apply;
            }

            // Process current touching state
            else
            {
                // Nothing to do for touching
            }
        }

        // If state is holding
        else if (state == VirtualHandState.Holding)
        {
            // If grasp has been broken
            if (grasp == null)
            {
                // Update state to open
                state = VirtualHandState.Open;
            }

            // If button has been released and grasp still exists
            else if (!button.GetPress() && grasp != null)
            {
                // Get rigidbody of grasped target
                Rigidbody target = grasp.GetComponent <Rigidbody>();
                // Break grasp
                DestroyImmediate(grasp);

                // Apply physics to target in the event of attempting to throw it
                target.velocity        = hand.velocity * speed;
                target.angularVelocity = hand.angularVelocity * speed;

                // Update state to open
                state = VirtualHandState.Open;
            }


            // Process current holding state
            else
            {
                // Nothing to do for holding
            }
        }

        // if state is displacing
        else if (state == VirtualHandState.Apply)
        {
            if (grasp == null && !grip.GetPressDown() && !hand.triggerOngoing)
            {
                // Update state to open
                state = VirtualHandState.Open;
            }
            else if (grasp == null && !grip.GetPressDown() && hand.triggerOngoing)
            {
                state = VirtualHandState.Touching;
            }


            else
            {
            }
        }
    }
コード例 #5
0
    // FixedUpdate is not called every graphical frame but rather every physics frame
    void FixedUpdate()
    {
        // If state is open
        if (state == VirtualHandState.Open)
        {
            // If the hand is touching something
            if (hand.triggerOngoing)
            {
                // Change state to touching
                Debug.Log("Touching");
                state = VirtualHandState.Touching;
            }

            // If the hand is closed
            else if (button.GetPress() && !menu.GetPressDown())
            {
                // Change state to closed
                state     = VirtualHandState.Closed;
                hand.type = AffectType.Physical;
            }

            else if (menu.GetPressDown())
            {
                if (button.GetPressDown())
                {
                    Debug.Log("HandleTriggerClicked");
                    if (EventSystem.current.currentSelectedGameObject != null)
                    {
                        ExecuteEvents.Execute(EventSystem.current.currentSelectedGameObject, new PointerEventData(EventSystem.current), ExecuteEvents.submitHandler);
                        return;
                    }
                }

                GameObject menuUIObj;
                GameObject menuBeamObj;
                menuUIObj = GameObject.Find("MainMenuObjectHelper");

                menustatus = menuUIObj.GetComponent <MenuUI>().isOn;
                //menustatus = menuUIObj.activeInHierarchy;

                menuBeamObj    = GameObject.Find("MenuBeamHelper");
                menuBeamStatus = menuBeamObj.GetComponent <MenuBeam>().isOn;

                if (menustatus == true)
                {
                    Debug.Log("TurnOff");
                    menustatus = false;
                    menuUIObj.GetComponent <MenuUI>().isOn     = menustatus;
                    menuBeamObj.GetComponent <MenuBeam>().isOn = menustatus;
                }
                else if (menustatus == false)
                {
                    Debug.Log("TurnOn");
                    menustatus = true;
                    menuUIObj.GetComponent <MenuUI>().isOn     = menustatus;
                    menuBeamObj.GetComponent <MenuBeam>().isOn = menustatus;
                }

                // Change state to Select
                state = VirtualHandState.Select;
            }

            else
            {
                // do nothing
            }
        }

        //If state is closed
        if (state == VirtualHandState.Closed)
        {
            if (!button.GetPress())
            {
                //change state to open
                state     = VirtualHandState.Open;
                hand.type = AffectType.Virtual;
            }

            else
            {
                //do nothing
            }
        }

        // If state is touching
        else if (state == VirtualHandState.Touching)
        {
            // If the hand is not touching something
            if (!hand.triggerOngoing)
            {
                // Change state to open
                state = VirtualHandState.Open;
            }

            // If the hand is touching something and the button is pressed
            else if (hand.triggerOngoing && button.GetPress())
            {
                // Fetch touched target
                Collider target = hand.ongoingTriggers[0];

                if (target.GetComponent <Status>())
                {
                    status = target.GetComponent <Status>().isOn;
                    if (status == true)
                    {
                        Debug.Log("TurnOff");
                        status = false;
                        target.GetComponent <Status>().isOn = status;
                    }
                    else
                    {
                        Debug.Log("TurnOn");
                        status = true;
                        target.GetComponent <Status>().isOn = status;
                    }
                }

                if (target.GetComponent <Vision>())
                {
                    status = target.GetComponent <Vision>().isOn;
                    if (status == true)
                    {
                        status = false;
                        target.GetComponent <Vision>().isOn = status;
                        //grasp = target.GetComponent<Vision>().goggle.gameObject.AddComponent<FixedJoint>();
                        //grasp.connectedBody = hand.gameObject.GetComponent<Rigidbody>();
                    }
                }


                // Create a fixed joint between the hand and the target
                grasp = target.gameObject.AddComponent <FixedJoint>();
                // Set the connection
                grasp.connectedBody = hand.gameObject.GetComponent <Rigidbody>();

                if (target.gameObject.tag == "goggle")
                {
                    hand.gameObject.tag = "goggle";
                }


                // Change state to holding
                state = VirtualHandState.Holding;
            }

            //else if (hand.triggerOngoing && grip.GetPressDown())
            //{
            //    Debug.Log("Apply");
            //    Collider target = hand.ongoingTriggers[0];

            //    if (target.GetComponent<Status>())
            //    {
            //        status = target.GetComponent<Status>().isOn;
            //        if (status == true)
            //        {
            //            Debug.Log("TurnOff");
            //            status = false;
            //            target.GetComponent<Status>().isOn = status;

            //        }
            //        else if (status == false)
            //        {
            //            Debug.Log("TurnOn");
            //            status = true;
            //            target.GetComponent<Status>().isOn = status;
            //        }
            //    }

            //    if (target.GetComponent<Goggles>())
            //    {
            //        status = target.GetComponent<Goggles>().isOn;
            //        if (status == true)
            //        {
            //            Debug.Log("TurnOff");
            //            status = false;
            //            target.GetComponent<Goggles>().isOn = status;

            //        }
            //        else if (status == false)
            //        {
            //            Debug.Log("TurnOn");
            //            status = true;
            //            target.GetComponent<Goggles>().isOn = status;
            //        }
            //    }

            //    if (target.GetComponent<Vision>())
            //    {
            //        status = target.GetComponent<Vision>().isOn;
            //        if (status == true)
            //        {
            //            Debug.Log("TurnOff");
            //            status = false;
            //            target.GetComponent<Vision>().isOn = status;

            //        }
            //        else if (status == false)
            //        {
            //            Debug.Log("TurnOn");
            //            status = true;
            //            target.GetComponent<Vision>().isOn = status;
            //        }
            //    }

            //    state = VirtualHandState.Apply;

            //}

            // Process current touching state
            else
            {
                // Nothing to do for touching
            }
        }

        // If state is holding
        else if (state == VirtualHandState.Holding)
        {
            // If grasp has been broken
            if (grasp == null)
            {
                // Update state to open
                state = VirtualHandState.Open;
            }

            // If button has been released and grasp still exists
            else if (!button.GetPress() && grasp != null)
            {
                // Get rigidbody of grasped target
                Rigidbody target = grasp.GetComponent <Rigidbody>();
                // Break grasp
                DestroyImmediate(grasp);

                // Apply physics to target in the event of attempting to throw it
                target.velocity        = hand.velocity * speed;
                target.angularVelocity = hand.angularVelocity * speed;

                hand.gameObject.tag = "hands";

                // Update state to open
                state = VirtualHandState.Open;
            }


            // Process current holding state
            else
            {
                // Nothing to do for holding
            }
        }

        // if state is displacing
        //else if (state == VirtualHandState.Apply)
        //{

        //    if (grasp == null && !grip.GetPressDown() && !hand.triggerOngoing)
        //    {
        //        // Update state to open
        //        state = VirtualHandState.Open;
        //    }
        //    else if (grasp == null && !grip.GetPressDown() && hand.triggerOngoing)
        //    {
        //        state = VirtualHandState.Touching;
        //    }

        //    else
        //    {

        //    }

        //}

        else if (state == VirtualHandState.Select)
        {
            if (!menu.GetPressDown())
            {
                state = VirtualHandState.Open;
            }
        }
    }