Ejemplo n.º 1
0
    /// <summary>
    /// Recenters the head pose.
    /// </summary>
    public void RecenterPose()
    {
#if USING_XR_SDK
        XRInputSubsystem currentInputSubsystem = OVRManager.GetCurrentInputSubsystem();
        if (currentInputSubsystem != null)
        {
            currentInputSubsystem.TryRecenter();
        }
#elif !REQUIRES_XR_SDK
#pragma warning disable 618
        InputTracking.Recenter();
#pragma warning restore 618
#endif

        // The current poses are cached for the current frame and won't be updated immediately
        // after UnityEngine.VR.InputTracking.Recenter(). So we need to wait until next frame
        // to trigger the RecenteredPose delegate. The application could expect the correct pose
        // when the RecenteredPose delegate get called.
        recenterRequested           = true;
        recenterRequestedFrameCount = Time.frameCount;

#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
        OVRMixedReality.RecenterPose();
#endif
    }
Ejemplo n.º 2
0
    private static bool ValidateProperty(Node nodeType, ref NodeState requestedNodeState)
    {
        InputTracking.GetNodeStates(nodeStateList);

        if (nodeStateList.Count == 0)
        {
            return(false);
        }

        bool nodeStateFound = false;

        requestedNodeState = nodeStateList[0];

        for (int i = 0; i < nodeStateList.Count; i++)
        {
            if (nodeStateList[i].nodeType == nodeType)
            {
                requestedNodeState = nodeStateList[i];
                nodeStateFound     = true;
                break;
            }
        }

        return(nodeStateFound);
    }
Ejemplo n.º 3
0
        void UpdateCameraTransform()
        {
            if (!m_Camera)
            {
                return;
            }

#pragma warning disable 618
            var cameraTransform = m_Camera.transform;
            cameraTransform.localPosition = InputTracking.GetLocalPosition(XRNode.Head);
            cameraTransform.localRotation = InputTracking.GetLocalRotation(XRNode.Head);
#pragma warning restore 618
        }
Ejemplo n.º 4
0
        void UpdateCameraTransform()
        {
            if (!m_Camera)
            {
                return;
            }

            var cameraTransform = m_Camera.transform;

#if UNITY_2017_2_OR_NEWER
            cameraTransform.localPosition = InputTracking.GetLocalPosition(XRNode.Head);
            cameraTransform.localRotation = InputTracking.GetLocalRotation(XRNode.Head);
#endif
        }
Ejemplo n.º 5
0
        public static void GetDevicesAtXRNode(XRNode node, List <InputDevice> inputDevices)
        {
            if (null == inputDevices)
            {
                throw new ArgumentNullException("inputDevices");
            }

            List <UInt64> deviceIds = new List <UInt64>();

            InputTracking.GetDeviceIdsAtXRNode_Internal(node, deviceIds);

            inputDevices.Clear();
            foreach (var deviceId in deviceIds)
            {
                InputDevice nodeDevice = new InputDevice(deviceId);
                if (nodeDevice.isValid)
                {
                    inputDevices.Add(nodeDevice);
                }
            }
        }
    // Update is called once per frame
    void Update()
    {
        if (!listening && Input.GetMouseButtonDown(0))
        {
            listening = true;
        }
                #if UNITY_EDITOR
        if (listening)
        {
            Cursor.lockState = CursorLockMode.Locked;
            x += (Input.GetAxis("Mouse X") * _turnRate * Time.deltaTime);
            y -= (Input.GetAxis("Mouse Y") * _turnRate * Time.deltaTime);
            Quaternion rotation = Quaternion.Euler(y, x, 0f);
//			transform.position = rotation * transform.position;
            transform.rotation = rotation;
        }
                #else
        transform.localRotation = XRInput.GetLocalRotation(XRNode.CenterEye);
        Debug.Log(XRInput.GetLocalRotation(XRNode.CenterEye));
                #endif
    }
Ejemplo n.º 7
0
    public virtual Matrix4x4 ComputeTrackReferenceMatrix()
    {
        if (centerEyeAnchor == null)
        {
            Debug.LogError("centerEyeAnchor is required");
            return(Matrix4x4.identity);
        }

        // The ideal approach would be using UnityEngine.VR.VRNode.TrackingReference, then we would not have to depend on the OVRCameraRig. Unfortunately, it is not available in Unity 5.4.3

        OVRPose headPose;

        headPose.position    = InputTracking.GetLocalPosition(Node.Head);
        headPose.orientation = InputTracking.GetLocalRotation(Node.Head);

        OVRPose   invHeadPose   = headPose.Inverse();
        Matrix4x4 invHeadMatrix = Matrix4x4.TRS(invHeadPose.position, invHeadPose.orientation, Vector3.one);

        Matrix4x4 ret = centerEyeAnchor.localToWorldMatrix * invHeadMatrix;

        return(ret);
    }
Ejemplo n.º 8
0
        public static void GetDevicesAtXRNode(XRNode node, List <InputDevice> inputDevices)
        {
            bool flag = inputDevices == null;

            if (flag)
            {
                throw new ArgumentNullException("inputDevices");
            }
            List <ulong> list = new List <ulong>();

            InputTracking.GetDeviceIdsAtXRNode_Internal(node, list);
            inputDevices.Clear();
            foreach (ulong current in list)
            {
                InputDevice item    = new InputDevice(current);
                bool        isValid = item.isValid;
                if (isValid)
                {
                    inputDevices.Add(item);
                }
            }
        }
Ejemplo n.º 9
0
    // [Command]
    // public void CmdFireProjectile()
    // {
    //     if (NetworkServer.active)
    //     {
    //         prefabInstance = Instantiate(projectilePrefab, spawnPos.position, spawnPos.transform.rotation);
    //         prefabInstance.GetComponent<Rigidbody>().velocity = spawnPos.transform.forward * 2;
    //         NetworkServer.Spawn(prefabInstance);
    //     }
    // }
    // public void Fire(float fireRate)
    // {
    //     CmdFireProjectile();
    // }
    void Update()
    {
        if (!isLocalPlayer)
        {
            if (OvrCam != null)
            {
                Destroy(OvrCam);
            }
        }
        else
        {
            if (camL != null)
            {
                if (camL.tag != "MainCamera")
                {
                    camL.tag     = "MainCamera";
                    camL.enabled = true;
                }
                if (camR.tag != "MainCamera")
                {
                    camR.tag     = "MainCamera";
                    camR.enabled = true;
                }
            }

            // if (OVRInput.Get(OVRInput.Button.PrimaryHandTrigger))
            // {
            //     Fire(1);
            // }
            // if (OVRInput.Get(OVRInput.Button.Two))
            // {
            //     Fire(1);
            // }
            // if (OVRInput.Get(OVRInput.Button.Three))
            // {
            //     Fire(1);
            // }
            // if (OVRInput.Get(OVRInput.Button.Four))
            // {
            //     Fire(1);
            // }

            //handle animations
            if (OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).x != 0 || OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).y != 0)
            {
                //anim.SetBool("Idle", false);
                //GetComponent<LocalAnimationControl>().CmdUpdateAnim("run");
            }
            else
            {
                //anim.SetBool("Idle", true);
                // GetComponent<LocalAnimationControl>().CmdUpdateAnim("idle");
            }

            //"hands" need to put in hand models and animations, but this is how to get the position:
            leftHandAnchor.localRotation  = InputTracking.GetLocalRotation(Node.LeftHand);
            rightHandAnchor.localRotation = InputTracking.GetLocalRotation(Node.RightHand);
            leftHandAnchor.localPosition  = InputTracking.GetLocalPosition(Node.LeftHand);
            rightHandAnchor.localPosition = InputTracking.GetLocalPosition(Node.RightHand);

            //If we want to pull from OVRinput
            Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);

            if (primaryAxis.y > 0.0f)
            {
                pos += (primaryAxis.y * transform.forward * Time.deltaTime * speed);
            }

            if (primaryAxis.y < 0.0f)
            {
                pos += (Mathf.Abs(primaryAxis.y) * -transform.forward * Time.deltaTime * speed);
            }

            if (primaryAxis.x < 0.0f)
            {
                pos += (Mathf.Abs(primaryAxis.x) * -transform.right * Time.deltaTime * speed);
            }

            if (primaryAxis.x > 0.0f)
            {
                pos += (primaryAxis.x * transform.right * Time.deltaTime * speed);
            }

            transform.position = pos;

            Vector3 euler         = transform.rotation.eulerAngles;
            Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
            euler.y                += secondaryAxis.x;
            transform.rotation      = Quaternion.Euler(euler);
            transform.localRotation = Quaternion.Euler(euler);
        }
    }
Ejemplo n.º 10
0
        public static InputDevice GetDeviceAtXRNode(XRNode node)
        {
            UInt64 deviceId = InputTracking.GetDeviceIdAtXRNode(node);

            return(new InputDevice(deviceId));
        }
Ejemplo n.º 11
0
 public void StopHaptics()
 {
     InputTracking.StopHaptics(m_DeviceId);
 }
Ejemplo n.º 12
0
 public bool SendHapticBuffer(uint channel, byte[] buffer)
 {
     return(InputTracking.SendHapticBuffer(m_DeviceId, channel, buffer));
 }
Ejemplo n.º 13
0
 // Haptics
 public bool SendHapticImpulse(uint channel, float amplitude, float duration = 1.0f)
 {
     return(InputTracking.SendHapticImpulse(m_DeviceId, channel, amplitude, duration));
 }
Ejemplo n.º 14
0
    protected virtual void UpdateAnchors()
    {
        EnsureGameObjectIntegrity();

        if (!Application.isPlaying)
        {
            return;
        }

        if (_skipUpdate)
        {
            centerEyeAnchor.FromOVRPose(OVRPose.identity, true);
            leftEyeAnchor.FromOVRPose(OVRPose.identity, true);
            rightEyeAnchor.FromOVRPose(OVRPose.identity, true);

            return;
        }

        bool monoscopic = OVRManager.instance.monoscopic;
        bool hmdPresent = OVRNodeStateProperties.IsHmdPresent();

        OVRPose tracker = OVRManager.tracker.GetPose();

        trackerAnchor.localRotation = tracker.orientation;

        Quaternion emulatedRotation = Quaternion.Euler(-OVRManager.instance.headPoseRelativeOffsetRotation.x, -OVRManager.instance.headPoseRelativeOffsetRotation.y, OVRManager.instance.headPoseRelativeOffsetRotation.z);

        centerEyeAnchor.localRotation = hmdPresent ? InputTracking.GetLocalRotation(Node.CenterEye) : emulatedRotation;
        leftEyeAnchor.localRotation   = (!hmdPresent || monoscopic) ? centerEyeAnchor.localRotation : InputTracking.GetLocalRotation(Node.LeftEye);
        rightEyeAnchor.localRotation  = (!hmdPresent || monoscopic) ? centerEyeAnchor.localRotation : InputTracking.GetLocalRotation(Node.RightEye);

        leftHandAnchor.localRotation  = InputTracking.GetLocalRotation(Node.LeftHand);
        rightHandAnchor.localRotation = InputTracking.GetLocalRotation(Node.RightHand);

        trackerAnchor.localPosition = tracker.position;

        centerEyeAnchor.localPosition = hmdPresent ? InputTracking.GetLocalPosition(Node.CenterEye) : OVRManager.instance.headPoseRelativeOffsetTranslation;
        leftEyeAnchor.localPosition   = (!hmdPresent || monoscopic) ? centerEyeAnchor.localPosition : InputTracking.GetLocalPosition(Node.LeftEye);
        rightEyeAnchor.localPosition  = (!hmdPresent || monoscopic) ? centerEyeAnchor.localPosition : InputTracking.GetLocalPosition(Node.RightEye);

        leftHandAnchor.localPosition  = InputTracking.GetLocalPosition(Node.LeftHand);
        rightHandAnchor.localPosition = InputTracking.GetLocalPosition(Node.RightHand);

        RaiseUpdatedAnchorsEvent();
    }
Ejemplo n.º 15
0
    protected virtual void UpdateAnchors()
    {
        EnsureGameObjectIntegrity();

        if (!Application.isPlaying)
        {
            return;
        }

        if (_skipUpdate)
        {
            centerEyeAnchor.FromOVRPose(OVRPose.identity, true);
            leftEyeAnchor.FromOVRPose(OVRPose.identity, true);
            rightEyeAnchor.FromOVRPose(OVRPose.identity, true);

            return;
        }

        bool monoscopic = OVRManager.instance.monoscopic;
        bool hmdPresent = OVRNodeStateProperties.IsHmdPresent();

        OVRPose tracker = OVRManager.tracker.GetPose();

        trackerAnchor.localRotation = tracker.orientation;

        Quaternion emulatedRotation = Quaternion.Euler(-OVRManager.instance.headPoseRelativeOffsetRotation.x, -OVRManager.instance.headPoseRelativeOffsetRotation.y, OVRManager.instance.headPoseRelativeOffsetRotation.z);

        centerEyeAnchor.localRotation = hmdPresent ? InputTracking.GetLocalRotation(Node.CenterEye) : emulatedRotation;
        leftEyeAnchor.localRotation   = (!hmdPresent || monoscopic) ? centerEyeAnchor.localRotation : InputTracking.GetLocalRotation(Node.LeftEye);
        rightEyeAnchor.localRotation  = (!hmdPresent || monoscopic) ? centerEyeAnchor.localRotation : InputTracking.GetLocalRotation(Node.RightEye);

        //Need this for controller offset because if we're on OpenVR, we want to set the local poses as specified by Unity, but if we're not, OVRInput local position is the right anchor
        if (OVRManager.loadedXRDevice == OVRManager.XRDevice.OpenVR)
        {
            leftHandAnchor.localPosition  = InputTracking.GetLocalPosition(Node.LeftHand);
            rightHandAnchor.localPosition = InputTracking.GetLocalPosition(Node.RightHand);
            leftHandAnchor.localRotation  = InputTracking.GetLocalRotation(Node.LeftHand);
            rightHandAnchor.localRotation = InputTracking.GetLocalRotation(Node.RightHand);
        }
        else
        {
            leftHandAnchor.localPosition  = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
            rightHandAnchor.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
            leftHandAnchor.localRotation  = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
            rightHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
        }

        trackerAnchor.localPosition = tracker.position;

        centerEyeAnchor.localPosition = hmdPresent ? InputTracking.GetLocalPosition(Node.CenterEye) : OVRManager.instance.headPoseRelativeOffsetTranslation;
        leftEyeAnchor.localPosition   = (!hmdPresent || monoscopic) ? centerEyeAnchor.localPosition : InputTracking.GetLocalPosition(Node.LeftEye);
        rightEyeAnchor.localPosition  = (!hmdPresent || monoscopic) ? centerEyeAnchor.localPosition : InputTracking.GetLocalPosition(Node.RightEye);

        OVRPose leftOffsetPose  = OVRPose.identity;
        OVRPose rightOffsetPose = OVRPose.identity;

        if (OVRManager.loadedXRDevice == OVRManager.XRDevice.OpenVR)
        {
            leftOffsetPose  = OVRManager.GetOpenVRControllerOffset(Node.LeftHand);
            rightOffsetPose = OVRManager.GetOpenVRControllerOffset(Node.RightHand);

            //Sets poses of left and right nodes, local to the tracking space.
            OVRManager.SetOpenVRLocalPose(trackingSpace.InverseTransformPoint(leftControllerAnchor.position),
                                          trackingSpace.InverseTransformPoint(rightControllerAnchor.position),
                                          Quaternion.Inverse(trackingSpace.rotation) * leftControllerAnchor.rotation,
                                          Quaternion.Inverse(trackingSpace.rotation) * rightControllerAnchor.rotation);
        }
        rightControllerAnchor.localPosition = rightOffsetPose.position;
        rightControllerAnchor.localRotation = rightOffsetPose.orientation;
        leftControllerAnchor.localPosition  = leftOffsetPose.position;
        leftControllerAnchor.localRotation  = leftOffsetPose.orientation;

        RaiseUpdatedAnchorsEvent();
    }
Ejemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        //if (!isLocalPlayer)
        //{
        //	Destroy(ovrCamRig);
        //	AssignRemoteLayer();
        //}
        //else
        //{
        //keep camera good when another player joins
        //if (leftEye.tag != "MainCamera")
        //{
        //	leftEye.tag = "MainCamera";
        //	leftEye.enabled = true;
        //}
        //if (rightEye.tag != "MainCamera")
        //{
        //	rightEye.tag = "MainCamera";
        //	rightEye.enabled = true;
        //}

        //keep hand positions good when another player joins
        leftHand.localRotation  = InputTracking.GetLocalRotation(Node.LeftHand);
        rightHand.localRotation = InputTracking.GetLocalRotation(Node.RightHand);
        leftHand.localPosition  = InputTracking.GetLocalPosition(Node.LeftHand);
        rightHand.localPosition = InputTracking.GetLocalPosition(Node.RightHand);

        //handle position and rotation of the player
        Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);

        ////(triggers walking sound and animation)
        if (primaryAxis.y != 0f || Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.Q))
        {
            animator.SetBool("isWalking", true);
        }
        else
        {
            animator.SetBool("isWalking", false);
        }

        //update pos every frame (seems to slow PC a bit)
        pos = transform.position;


        _isGrounded = Physics.CheckSphere(_groundChecker.position, GroundDistance, Ground, QueryTriggerInteraction.Ignore);

        if (_isGrounded)
        {
            if (airBorn)
            {
                SoundManager.Instance.PlayOneShot(SoundManager.Instance.landingBoom);
            }

            airBorn = false;
            Debug.Log("Currently Grounded");
        }
        if (!_isGrounded)
        {
            airBorn = true;
            Debug.Log("The Mech is NOT Currently Grounded!!!");
            pos += (Physics.gravity * 0.7f);
        }


        if (Input.GetButtonDown("Jump") && _isGrounded)
        {
            airBorn = true;
            //_body.AddForce(Vector3.up * Mathf.Sqrt(JumpHeight * Physics.gravity.y), ForceMode.VelocityChange);
        }

        //if speedboost triggered...
        if (speedBoosted == true)
        {
            //go fast
            currentSpeed = BoostSpeed;
        }
        else
        {
            //go regular speed
            currentSpeed = speed;
        }

        if (primaryAxis.y > 0f || Input.GetKey(KeyCode.W))
        {
            //animator.SetBool("isWalking", true);

            if (primaryAxis.y > 0f)
            {
                pos += (primaryAxis.y * transform.forward * Time.deltaTime * currentSpeed);
            }
            if (Input.GetKey(KeyCode.W))
            {
                pos += (transform.forward * Time.deltaTime * currentSpeed);
            }
        }
        else if (primaryAxis.y < 0f || Input.GetKey(KeyCode.S))
        {
            animator.SetBool("isWalkBack", true);

            if (primaryAxis.y < 0f)
            {
                pos += (Mathf.Abs(primaryAxis.y) * -transform.forward * Time.deltaTime * currentSpeed);
            }
            if (Input.GetKey(KeyCode.S))
            {
                pos += (-transform.forward * Time.deltaTime * currentSpeed);
            }
        }
        else
        {
            animator.SetBool("isWalkBack", false);
        }

        if (primaryAxis.x > 0f || Input.GetKey(KeyCode.D))
        {
            //animator.SetBool("isWalking", true);

            if (primaryAxis.x > 0f)
            {
                pos += (Mathf.Abs(primaryAxis.x) * transform.right * Time.deltaTime * currentSpeed);
            }
            if (Input.GetKey(KeyCode.D))
            {
                pos += (transform.right * Time.deltaTime * currentSpeed);
            }
        }
        else if (primaryAxis.x < 0f || Input.GetKey(KeyCode.A))
        {
            //animator.SetBool("isWalking", true);

            if (primaryAxis.x < 0f)
            {
                pos += (Mathf.Abs(primaryAxis.x) * -transform.right * Time.deltaTime * currentSpeed);
            }
            if (Input.GetKey(KeyCode.A))
            {
                pos += (-transform.right * Time.deltaTime * currentSpeed);
            }
        }

        transform.position = pos;

        Vector3 euler         = transform.rotation.eulerAngles;
        Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);

        if (Input.GetKey(KeyCode.E))
        {
            euler.y += .5f;
        }

        if (Input.GetKey(KeyCode.Q))
        {
            euler.y -= .5f;
        }

        euler.y           += secondaryAxis.x;
        transform.rotation = Quaternion.Euler(euler);

        //maybe set local rotation too?
        //transform.localRotation = Quaternion.Euler(euler);

        //suicide kill test
        if (Input.GetKeyDown(KeyCode.K))
        {
            var healthScript = GetComponent <Health>();
            if (healthScript != null)
            {
                Debug.Log("Self Destruct Initiated");
                Debug.Log("Current Health is now " + healthScript.currentHealth);
                healthScript.RpcTakeDamage(100);
            }
        }
        //}
    }
Ejemplo n.º 17
0
    public Vector3 GetNodeStateProperty(Node nodeType, NodeStatePropertyType propertyType)
    {
        List <NodeState> nodeStateList = new List <NodeState>();

        InputTracking.GetNodeStates(nodeStateList);

        if (nodeStateList.Count == 0)
        {
            return(Vector3.zero);
        }

        bool      nodeStateFound     = false;
        NodeState requestedNodeState = nodeStateList[0];

        for (int i = 0; i < nodeStateList.Count; i++)
        {
            if (nodeStateList[i].nodeType == nodeType)
            {
                requestedNodeState = nodeStateList[i];
                nodeStateFound     = true;
                break;
            }
        }

        if (!nodeStateFound)
        {
            return(Vector3.zero);
        }

        Vector3 retVec;

        if (propertyType == NodeStatePropertyType.Acceleration)
        {
            if (requestedNodeState.TryGetAcceleration(out retVec))
            {
                return(retVec);
            }
        }
        else if (propertyType == NodeStatePropertyType.AngularAcceleration)
        {
#if UNITY_2017_2_OR_NEWER
            if (requestedNodeState.TryGetAngularAcceleration(out retVec))
            {
                retVec = retVec * Mathf.Rad2Deg;
                return(retVec);
            }
#endif
        }
        else if (propertyType == NodeStatePropertyType.Velocity)
        {
            if (requestedNodeState.TryGetVelocity(out retVec))
            {
                return(retVec);
            }
        }
        else if (propertyType == NodeStatePropertyType.AngularVelocity)
        {
#if UNITY_2017_2_OR_NEWER
            if (requestedNodeState.TryGetAngularVelocity(out retVec))
            {
                retVec = retVec * Mathf.Rad2Deg;
                return(retVec);
            }
#endif
        }

        return(Vector3.zero);
    }
Ejemplo n.º 18
0
 public bool TryGetHapticCapabilities(out HapticCapabilities capabilities)
 {
     return(InputTracking.TryGetHapticCapabilities(m_DeviceId, out capabilities));
 }
Ejemplo n.º 19
0
        public static InputDevice GetDeviceAtXRNode(XRNode node)
        {
            ulong deviceIdAtXRNode = InputTracking.GetDeviceIdAtXRNode(node);

            return(new InputDevice(deviceIdAtXRNode));
        }
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            Destroy(ovrCamRig);
        }
        else
        {
            //Take care of camera transporting when players join.
            if (leftEye.tag != "MainCamera")
            {
                leftEye.tag     = "MainCamera";
                leftEye.enabled = true;
            }
            if (rightEye.tag != "MainCamera")
            {
                rightEye.tag     = "MainCamera";
                rightEye.enabled = true;
            }

            //handle animations
            if (OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).x != 0 || OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).y != 0)
            {
                //Set animatio to running over the server
                GetComponent <LocalAnimationControl>().CmdUpdateAnim("run");
                anim.SetBool("Idle", false);
            }
            else
            {
                //Set animation to nothing over the server.
                GetComponent <LocalAnimationControl>().CmdUpdateAnim("idle");
                anim.SetBool("Idle", true);
            }

            //Take care of hand position tracking
            leftHand.localRotation  = InputTracking.GetLocalRotation(Node.LeftHand);
            leftHand.localPosition  = InputTracking.GetLocalPosition(Node.LeftHand);
            rightHand.localRotation = InputTracking.GetLocalRotation(Node.RightHand);
            rightHand.localPosition = InputTracking.GetLocalPosition(Node.RightHand);

            //Handle position and rotation of player.
            Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);

            if (primaryAxis.y > 0f)
            {
                pos += (primaryAxis.y * transform.forward * Time.deltaTime * speed);
            }
            if (primaryAxis.y < 0f)
            {
                pos += (Mathf.Abs(primaryAxis.y) * -transform.forward * Time.deltaTime * speed);
            }
            if (primaryAxis.x > 0f)
            {
                pos += (primaryAxis.x * transform.right * Time.deltaTime * speed);
            }
            if (primaryAxis.x < 0f)
            {
                pos += (Mathf.Abs(primaryAxis.x) * -transform.right * Time.deltaTime * speed);
            }

            transform.position = pos;

            Vector3 euler         = transform.rotation.eulerAngles;
            Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
            euler.y           += secondaryAxis.x;
            transform.rotation = Quaternion.Euler(euler);
            //Maybe set local rotation too?
            transform.localRotation = Quaternion.Euler(euler);
        }
    }