예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_controller == null)
        {
            m_controller = SixenseInput.GetController(m_hand);
        }
        else
        {
            if (startingH == 999 || m_controller.GetButtonDown(SixenseButtons.ONE))
            {
                startingH = m_controller.Rotation.eulerAngles.y;
                startingV = m_controller.Rotation.eulerAngles.x;
            }
            curH = -Mathf.DeltaAngle(m_controller.Rotation.eulerAngles.y, startingH);
            curV = -Mathf.DeltaAngle(m_controller.Rotation.eulerAngles.x, startingV);
            curH = curH > 30 ? 30 : curH;
            curH = curH < -30 ? -30 : curH;
            curV = curV > 30 ? 30 : curV;
            curV = curV < -30 ? -30 : curV;

            cursorX = (curH + 30) / 60;
            cursorY = (curV + 30) / 60;

            Quaternion rotation = Quaternion.identity;
            rotation.eulerAngles    = new Vector3(curV, curH * 16 / 9, 0);
            transform.localRotation = rotation;

            Vector3 fwd = transform.TransformDirection(Vector3.forward);
            Debug.DrawRay(transform.position, fwd * 100, Color.green);
            //if (Physics.Raycast(transform.position, fwd, 10)) {
            //	print("There is something in front of the object!");
            //}

            if (m_controller.GetButtonDown(SixenseButtons.TRIGGER) && !dragging)
            {
                RaycastHit hit = new RaycastHit();
                if (Physics.Raycast(transform.position, fwd, out hit, 100) && hit.rigidbody)
                {
                    Debug.Log("Jacob is dumb");
                    dragging          = true;
                    target            = hit.rigidbody;
                    target.useGravity = false;
                    prevRotation      = m_controller.Rotation;
                    prevPosition      = (m_controller.Position);
                    prevLSP           = transform.position;
                }
            }
            if (m_controller.GetButton(SixenseButtons.TRIGGER) && dragging)
            {
                target.MovePosition(target.transform.position + transform.TransformDirection(m_controller.Position - prevPosition) / 10 + transform.position - prevLSP);
                prevLSP      = transform.position;
                prevPosition = (m_controller.Position);
            }
            if (m_controller.GetButtonUp(SixenseButtons.TRIGGER) && dragging)
            {
                dragging          = false;
                target.useGravity = true;
            }
        }
    }
예제 #2
0
    public override bool SelectionButtonWasReleased()
    {
        if (razer == null || !razer.Enabled)
        {
            return(false);
        }
        switch (selectionButton)
        {
        case SixenseButtons.BUMPER:
            return(razer.GetButtonUp(SixenseButtons.BUMPER));

        case SixenseButtons.FOUR:
            return(razer.GetButtonUp(SixenseButtons.FOUR));

        case SixenseButtons.JOYSTICK:
            return(razer.GetButtonUp(SixenseButtons.JOYSTICK));

        case SixenseButtons.ONE:
            return(razer.GetButtonUp(SixenseButtons.ONE));

        case SixenseButtons.START:
            return(razer.GetButtonUp(SixenseButtons.START));

        case SixenseButtons.THREE:
            return(razer.GetButtonUp(SixenseButtons.THREE));

        case SixenseButtons.TRIGGER:
            return(razer.GetButtonUp(SixenseButtons.TRIGGER));

        case SixenseButtons.TWO:
            return(razer.GetButtonUp(SixenseButtons.TWO));

        default:
            return(false);
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (controller == null)
        {
            controller = this.gameObject.GetComponent <SixenseHand>().m_controller;
        }

        if (controller != null &&
            curObject != null &&
            curObject.GetComponent <Rigidbody>() != null &&
            (controller.GetButtonDown(SixenseButtons.TRIGGER)))
        {
            Debug.Log("trying");
            curObject.transform.parent = this.transform;
            curObject.GetComponent <Rigidbody>().useGravity     = false;
            curObject.GetComponent <Rigidbody>().freezeRotation = true;
        }

        if (controller != null &&
            curObject != null &&
            curObject.GetComponent <Rigidbody>() != null &&
            (controller.GetButtonUp(SixenseButtons.TRIGGER)))
        {
            curObject.transform.parent = null;
            curObject.GetComponent <Rigidbody>().useGravity     = true;
            curObject.GetComponent <Rigidbody>().freezeRotation = false;
            curObject = null;
        }


        if (curObject != null &&
            curObject.GetComponent <Rigidbody>() != null)
        {
            curObject.GetComponent <Rigidbody>().useGravity = false;
        }
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (VRSettings.enabled == true)
        {
            angles = InputTracking.GetLocalRotation(VRNode.Head);
            hands.transform.rotation = Quaternion.Euler(0, angles.eulerAngles.y + 90.0f, 0);
        }
        else
        {
            hands.transform.rotation = Quaternion.Euler(0, cam.transform.eulerAngles.y + 90.0f, 0);
        }

        //This test must always be done
        if (leftController == null || rightController == null)
        {
            leftController  = SixenseInput.GetController(SixenseHands.LEFT);
            rightController = SixenseInput.GetController(SixenseHands.RIGHT);
        }

        if ((leftController != null && leftController.Enabled) || (rightController != null && rightController.Enabled))
        {
            if ((leftController.GetButton(SixenseButtons.THREE) || rightController.GetButton(SixenseButtons.FOUR)) && tag == "Unselected")
            {
                gameObject.GetComponent <MeshRenderer> ().enabled = true;
            }

            if ((leftController.GetButton(SixenseButtons.THREE) || rightController.GetButton(SixenseButtons.FOUR)) && grabbedObject != null)
            {
                grabbedObject.transform.position = newPos;
                grabbedObject = null;
            }

            if ((leftController.GetButton(SixenseButtons.THREE) || rightController.GetButton(SixenseButtons.FOUR)) && (tag == "Selected" || transform.position != originalPos))
            {
                //Moves to original father
                transform.parent = originalFather.transform;

                //Moves to original position
                transform.position = originalPos;

                //Changes tag
                tag = "Unselected";

                gameObject.GetComponent <Renderer> ().material.color = startColor;
                gameObject.GetComponent <MeshRenderer> ().enabled    = true;

                //Returns rotation to original father
                if (originalFather.GetComponent("RotObj") as RotObj == null)
                {
                    originalFather.AddComponent <RotObj> ();
                }
            }


            if (leftController.GetButtonDown(SixenseButtons.TRIGGER) && gameObject.GetComponent <Renderer> ().material.color == Color.magenta)
            {
                //Saves original position
                newPos = transform.position;

                //Saves original scale
                originalScale = transform.localScale;

                transform.parent = lefthandFather.transform;
                grabbedObject    = this.gameObject;
                grabbedObject.transform.localScale = originalScale - new Vector3(2.0f, 2.0f, 2.0f);
                grabbedObject.GetComponent <Renderer> ().material.color = startColor;
                Destroy(originalFather.GetComponent <RotObj> ());
            }

            if (leftController.GetButtonUp(SixenseButtons.TRIGGER) && grabbedObject != null)
            {
                grabbedObject.transform.parent     = originalFather.transform;
                grabbedObject.transform.localScale = originalScale;

                //grabbedObject.tag = "Unselected";

                if (originalFather.GetComponent("RotObj") as RotObj == null)
                {
                    originalFather.AddComponent <RotObj> ();
                }
            }

            if (rightController.GetButtonDown(SixenseButtons.TRIGGER) && gameObject.GetComponent <Renderer> ().material.color == Color.magenta)
            {
                //Saves original position
                newPos = transform.position;

                //Saves original scale
                originalScale = transform.localScale;

                transform.parent = righthandFather.transform;
                grabbedObject    = this.gameObject;
                grabbedObject.transform.localScale = originalScale - new Vector3(2.0f, 2.0f, 2.0f);
                grabbedObject.GetComponent <Renderer> ().material.color = startColor;
                Destroy(originalFather.GetComponent <RotObj> ());
            }

            if (rightController.GetButtonUp(SixenseButtons.TRIGGER) && grabbedObject != null)
            {
                grabbedObject.transform.parent     = originalFather.transform;
                grabbedObject.transform.localScale = originalScale;

                //grabbedObject.tag = "Unselected";

                if (originalFather.GetComponent("RotObj") as RotObj == null)
                {
                    originalFather.AddComponent <RotObj> ();
                }
            }
        }
    }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown("2"))
        {
            GetComponent<ShieldController>().riseShield();

        }
        if (projectilePowerIsActive > 0 && Input.GetKeyDown("1") /*hand.GetComponent<Transform>().rotation.x < 0.5*/)
        {
            if (!GetComponentInChildren<ShootProjectile>().getThrowed())
            {
                GetComponentInChildren<ShootProjectile>().sendProjectile();
                projectilePowerIsActive--;
                soundGoalSource.Play();

            }
        }
        m_controller = SixenseInput.GetController(SixenseHands.LEFT);
        if (/*m_controller.GetButtonDown(SixenseButtons.TRIGGER)*/Input.GetKeyDown("3"))
        {
            if (ballTrapPowerIsActive > 0 && !ball.GetComponent<Control>().trapmat )
            {
                ballTrapPowerIsActive--;
                 ball.GetComponent<Control>().setTrap();
            }
        }

        if (blurVision)
        {
            if (resetTimer)
            {
                GetComponentInChildren<UnityStandardAssets.ImageEffects.Blur>().enabled = true;
                startTime = Time.time;
                resetTimer = false;
            }
            currentTimer = 5.0f - (Time.time - startTime);
            if (startTime + 5.0f < Time.time)
            {
                GetComponentInChildren<UnityStandardAssets.ImageEffects.Blur>().enabled = false;
                resetTimer = true;
                blurVision = false;
            }

        }
        if (shieldPowerIsActive > 0 && /*Input.GetKeyDown("2")*/m_controller.GetButtonUp(SixenseButtons.ONE))
        {
            if ((hand.GetComponent<Transform>().position.y - initialPosition) > 0.1)
            {
                GetComponent<ShieldController>().riseShield();
                shieldPowerIsActive--;
            }

         }
        if (terrainPowerIsActive > 0 && /*Input.GetKeyDown("2")*/m_controller.GetButtonUp(SixenseButtons.TWO))
        {
            if(localPointTerrainRaycasting.Equals(NULL_VECTOR3))
                localPointTerrainRaycasting = GetComponent<RayCasting>().sendRaycast();
            if ( !localPointTerrainRaycasting.Equals(NULL_VECTOR3) &&((hand.GetComponent<Transform>().position.y - initialPosition) > 0.1))
            {
                GetComponent<RaiseLowerTerrain>().riseController(localPointTerrainRaycasting);
                terrainPowerIsActive--;
                localPointTerrainRaycasting = NULL_VECTOR3;
                Debug.Log("raiseterrain");
            }

        }

        if(m_controller.GetButtonDown(SixenseButtons.ONE))
        {
            initialPosition = hand.GetComponent<Transform>().position.y;
        }
        if (m_controller.GetButtonDown(SixenseButtons.TWO))
        {
            initialPosition = hand.GetComponent<Transform>().position.y;
            Debug.Log(initialPosition);
        }
        if (m_controller.GetButtonDown(SixenseButtons.FOUR))
        {
            initialRotation = hand.GetComponent<Transform>().rotation.x;
        }
    }