Ejemplo n.º 1
0
    public void FixedUpdate()
    {
        /*
         * Objet utilisé pour un test : il faut créer une sphère, ou tout autre objet, dans Unity, et l'appeler BOULE.
         * Si ce script est présent quelque part, e.g. attaché à la sphère en question, quand on bouge la souris verticalement
         * ça fera bouger la sphère en conséquence.
         */
        //GameObject testBoule = GameObject.Find("BOULE");
        float   rotation = 0.0f;
        vrMouse mouse    = null;

        if (MiddleVR.VRDeviceMgr.GetMouse() != null)
        {
            mouse = MiddleVR.VRDeviceMgr.GetMouse();
        }

        if (Math.Abs(mouse.GetAxisValue(1)) > 0.1f)
        {
            rotation = mouse.GetAxisValue(1);
        }
        else if (Math.Abs(Input.GetAxis("Mouse Y")) > 0)
        {
            rotation = Input.GetAxis("Mouse Y");
        }

        /*
         * A décommenter pour le test de la boule, cf plus haut
         */
        //testBoule.transform.Translate(0,rotation*sensibility, 0);
        transform.Rotate(0, 0, rotation * sensibility);
    }
    void Update()
    {
        if (MiddleVR.VRDeviceMgr != null)
        {
            if (mouse.IsButtonPressed(1))
            {
                _x = mouse.GetAxisValue(0);                 //* _xSpeed;
                _y = mouse.GetAxisValue(1);                 // * _ySpeed;

                obj.transform.Rotate(Vector3.up * -_x, Space.World);
                obj.transform.Rotate(Vector3.left * _y, Space.World);
            }
        }
    }
Ejemplo n.º 3
0
    void FixedUpdate()
    {
        vrMouse mouse = null;
        float   rotation = 0.0f; float rotVert = 0;

        //Checking if MiddleVR is tracking the mouse
        if (MiddleVR.VRDeviceMgr.GetMouse() != null)
        {
            mouse = MiddleVR.VRDeviceMgr.GetMouse();
        }
        GameObject cam = GameObject.Find("Tete");

        //we don't want to rely on the wand here

        /*float wandHorizontal = MiddleVR.VRDeviceMgr.GetWandHorizontalAxisValue();
         * if (Math.Abs(wandHorizontal) > 0.1f)
         * {
         *      rotation = wandHorizontal;
         * }*/
        //GetAxisValue gives the position offset on the given axis since last update
        //0 means axis X
        if (Math.Abs(mouse.GetAxisValue(0)) > 0.001f)
        {
            rotation = mouse.GetAxisValue(0);
        }
        else if (Math.Abs(Input.GetAxis("Mouse X")) > 0)
        {
            rotation = Input.GetAxis("Mouse X");
        }

        if (Math.Abs(mouse.GetAxisValue(1)) > 0.001f)
        {
            rotVert = mouse.GetAxisValue(1);
        }
        else if (Math.Abs(Input.GetAxis("Mouse Y")) > 0)
        {
            rotVert = Input.GetAxis("Mouse Y");
        }

        transform.Rotate(0, rotation * sensibility, 0, Space.World);
        transform.Rotate(rotVert * sensibility, 0, 0, Space.Self);
    }