public bool isPositionTrackableRiftPresent() { if (OVRManager.capiHmd != null) { Ovr.HmdType ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; if ((OVRManager.capiHmd.GetTrackingState().StatusFlags & (uint)StatusBits.HmdConnected) != 0 && // !isplay.isPresent (ovrHmdVersion == HmdType.DK2 || ovrHmdVersion == HmdType.Other)) // Rift is DK2+ { return(true); } } return(false); }
void Start() { colliding = false; grounded = false; // Second substitution, because RUISKinectAndMecanimCombiner might have already erased the original one and re-created it skeletonController = gameObject.GetComponentInChildren <RUISSkeletonController>(); if (skeletonController) { bodyParts.Add(skeletonController.leftFoot); bodyParts.Add(skeletonController.rightFoot); kinectPlayerId = skeletonController.playerId; bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID; } else { Debug.LogError("RUISCharacterController script in game object '" + gameObject.name + "' did not find RUISSkeletonController component from it's child objects!"); } coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem; if (stabilizingCollider) { colliderComponent = stabilizingCollider.gameObject.GetComponent <Collider>(); if (colliderComponent) { if (characterPivotType == CharacterPivotType.KinectHead || characterPivotType == CharacterPivotType.KinectTorso) { if (coordinateSystem && inputManager.enableKinect && !coordinateSystem.setKinectOriginToFloor) { Debug.LogWarning("It is best to enable 'setKinectOriginToFloor' from RUISCoordinateSystem " + "when using Kinect and RUISCharacterController script."); } } if (colliderComponent.material) { originalMaterial = colliderComponent.material; } else { colliderComponent.material = new PhysicMaterial(); originalMaterial = colliderComponent.material; } if (dynamicMaterial == null) { dynamicMaterial = new PhysicMaterial(); dynamicMaterial.dynamicFriction = 0; dynamicMaterial.staticFriction = 0; dynamicMaterial.frictionCombine = PhysicMaterialCombine.Minimum; if (colliderComponent.material) { /*dynamicMaterial.bounceCombine = originalMaterial.bounceCombine; * dynamicMaterial.bounciness = originalMaterial.bounciness; * dynamicMaterial.staticFriction2 = originalMaterial.staticFriction2; * dynamicMaterial.dynamicFriction2 = originalMaterial.dynamicFriction2; * dynamicMaterial.frictionDirection2 = originalMaterial.frictionDirection2;*/ } } } } if ((characterPivotType == CharacterPivotType.KinectHead || characterPivotType == CharacterPivotType.KinectTorso) && (skeletonController && skeletonController.playerId != kinectPlayerId)) { Debug.LogError("The 'Kinect Player Id' variable in RUISCharacterController script in gameObject '" + gameObject.name + "is different from the Kinect Player Id of the RUISSkeletonController script (located in child " + "object '" + skeletonController.gameObject.name + "). Make sure that these two values are " + "the same."); } //#if UNITY_EDITOR //if(UnityEditorInternal.InternalEditorUtility.HasPro()) //#endif { try { bool isRiftConnected = false; if (OVRManager.display != null) { isRiftConnected = OVRManager.display.isPresent; } if (OVRManager.capiHmd != null) { ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; } if (useOculusPositionalTracking && ovrHmdVersion == Ovr.HmdType.DK1 || ovrHmdVersion == Ovr.HmdType.DKHD || ovrHmdVersion == Ovr.HmdType.None) { Debug.LogError("Can't use Oculus Rift's tracked position as a pivot with Oculus Rift " + ovrHmdVersion); useOculusPositionalTracking = false; } if (useOculusPositionalTracking && !isRiftConnected) { Debug.LogError("Can't use Oculus Rift's tracked position as a pivot because Oculus Rift is not connected."); useOculusPositionalTracking = false; } } catch (UnityException e) { useOculusPositionalTracking = false; Debug.LogError(e); } } if (GetComponentInChildren <RUISKinectAndMecanimCombiner>()) { kinectAndMecanimCombinerExists = true; } previousPosition = transform.position; }
private void updateCalibratableDevices() { List<string> dropDownChoices = new List<string>(); string currentSelection = this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent<UIPopupList>().selection; //dropDownChoices.Add ("Select device(s)"); if(inputManager.enableKinect) dropDownChoices.Add ("Kinect floor data"); if(inputManager.enableKinect2) dropDownChoices.Add ("Kinect 2 floor data"); bool isPositionTrackedOculusPresent = false; // #if UNITY_EDITOR // if(UnityEditorInternal.InternalEditorUtility.HasPro()) // #endif { try { if(OVRManager.capiHmd != null) ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; if(OVRManager.display != null) isPositionTrackedOculusPresent = OVRManager.display.isPresent && (ovrHmdVersion == Ovr.HmdType.DK2 || ovrHmdVersion == Ovr.HmdType.Other); } catch(UnityException e) { Debug.LogError (e); } } if(inputManager.enableKinect && inputManager.enableKinect2) dropDownChoices.Add ("Kinect - Kinect2"); if(inputManager.enableKinect && inputManager.enablePSMove) dropDownChoices.Add ("Kinect - PSMove"); if(inputManager.enableKinect2 && inputManager.enablePSMove) dropDownChoices.Add ("Kinect 2 - PSMove"); if(isPositionTrackedOculusPresent && inputManager.enableKinect2) dropDownChoices.Add ("Kinect 2 - Oculus DK2"); if(isPositionTrackedOculusPresent && inputManager.enableKinect) dropDownChoices.Add ("Kinect - Oculus DK2"); if(isPositionTrackedOculusPresent && inputManager.enablePSMove) dropDownChoices.Add ("PSMove - Oculus DK2"); if(dropDownChoices.Count == 0) { dropDownChoices.Add ("Select device(s)"); } this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent<UIPopupList>().items = dropDownChoices; if(!dropDownChoices.Contains(currentSelection)) { this.transform.Find ("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent<UIPopupList>().selection = dropDownChoices[0]; } }
private void handleInfotexts() { GameObject infotext_Changes_saved = this.transform.Find( "NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes saved").gameObject; GameObject infotext_Changes_are_not_saved_in_free_version = this.transform.Find( "NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes are not saved in free version").gameObject; GameObject infotext_Changes_not_saved_yet = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes not saved yet").gameObject; GameObject infotext_Rift_not_Detected = this.transform.Find( "NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Rift/Label - Rift not detected").gameObject; GameObject infotext_Oculus_DK1_detected = this.transform.Find( "NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Rift/Label - Oculus DK1 detected").gameObject; GameObject infotext_Oculus_DK2_detected = this.transform.Find( "NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Rift/Label - Oculus DK2 detected").gameObject; bool isRiftConnected = false; // #if UNITY_EDITOR // if(UnityEditorInternal.InternalEditorUtility.HasPro()) // #endif { try { if(OVRManager.display != null) isRiftConnected = OVRManager.display.isPresent; if(OVRManager.capiHmd != null) ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; } catch(UnityException e) { Debug.LogError(e); } } if(isRiftConnected && ovrHmdVersion == Ovr.HmdType.DK1) { infotext_Rift_not_Detected.SetActive(false); infotext_Oculus_DK1_detected.SetActive(true); infotext_Oculus_DK2_detected.SetActive(false); } else if(isRiftConnected && (ovrHmdVersion == Ovr.HmdType.DK2 || ovrHmdVersion == Ovr.HmdType.Other)) { infotext_Rift_not_Detected.SetActive(false); infotext_Oculus_DK2_detected.SetActive(true); infotext_Oculus_DK1_detected.SetActive(false); } else { infotext_Rift_not_Detected.SetActive(true); infotext_Oculus_DK1_detected.SetActive(false); infotext_Oculus_DK2_detected.SetActive(false); } if(!XmlImportExport.XmlHandlingFunctionalityAvailable()) { infotext_Changes_are_not_saved_in_free_version.SetActive(true); infotext_Changes_saved.SetActive(false); infotext_Changes_not_saved_yet.SetActive(false); } else { infotext_Changes_are_not_saved_in_free_version.SetActive(false); if(originalPSMoveIP == inputManager.PSMoveIP && originalPSMovePort == inputManager.PSMovePort && originalEnablePSMove == inputManager.enablePSMove && originalEnableKinect == inputManager.enableKinect && originalEnableKinect2 == inputManager.enableKinect2 && originalEnableJumpGesture == inputManager.jumpGestureEnabled && originalEnableHydra == inputManager.enableRazerHydra && originalKinectDriftCorrection == inputManager.kinectDriftCorrectionPreferred) { infotext_Changes_saved.SetActive(true); infotext_Changes_not_saved_yet.SetActive(false); } else { infotext_Changes_not_saved_yet.SetActive(true); infotext_Changes_saved.SetActive(false); } } }
void Start() { // Get information about Oculus Rift version and if it is connected ovrManager = FindObjectOfType<OVRManager>(); bool isRiftConnected = false; // #if UNITY_EDITOR // if(UnityEditorInternal.InternalEditorUtility.HasPro()) // #endif { try { if(OVRManager.capiHmd != null) ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; if(OVRManager.display != null) { isRiftConnected = OVRManager.display.isPresent; if(coordinateSystem && coordinateSystem.applyToRootCoordinates && headPositionInput == HeadPositionSource.OculusDK2) { OVRManager.display.RecenteredPose += RecenterPoseWarning; } } } catch(UnityException e) { Debug.LogError(e); } } if(headPositionInput == HeadPositionSource.OculusDK2) { if(!isRiftConnected) { headPositionInput = HeadPositionSource.None; this.transform.localPosition = defaultPosition; } else { OculusCounterPoseOffset(); if(coordinateSystem && coordinateSystem.applyToRootCoordinates) this.localRotation = coordinateSystem.GetOculusCameraYRotation(); } } if(headPositionInput == HeadPositionSource.Kinect1) { kinectSensorID = RUISSkeletonManager.kinect1SensorID; } if(headPositionInput == HeadPositionSource.Kinect2) { kinectSensorID = RUISSkeletonManager.kinect2SensorID; } inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; if( !inputManager && ( headPositionInput == HeadPositionSource.PSMove || headRotationInput == HeadRotationSource.PSMove || (externalDriftCorrection && compass == CompassSource.PSMove))) Debug.LogError("RUISInputManager script is missing from this scene!"); if(inputManager && !inputManager.enablePSMove) { if(headPositionInput == HeadPositionSource.PSMove) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for position " + "tracking, but you have not enabled it from InputManager."); if(headRotationInput == HeadRotationSource.PSMove) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for rotation " + "tracking, but you have not enabled it from InputManager."); if(externalDriftCorrection && compass == CompassSource.PSMove) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to use PS Move for yaw drift " + "correction, but you have not enabled it from InputManager."); } if (!skeletonManager) skeletonManager = FindObjectOfType(typeof(RUISSkeletonManager)) as RUISSkeletonManager; if( !skeletonManager && ( headPositionInput == HeadPositionSource.Kinect1 || headPositionInput == HeadPositionSource.Kinect2 || (!useOculusRiftRotation && (headRotationInput == HeadRotationSource.Kinect1 || headRotationInput == HeadRotationSource.Kinect2)) || (externalDriftCorrection && (compass == CompassSource.Kinect1 || compass == CompassSource.Kinect2)))) { Debug.LogError("RUISSkeletonManager script is missing from this scene!"); } if(inputManager && !inputManager.enableRazerHydra) { if(headPositionInput == HeadPositionSource.RazerHydra) Debug.LogWarning( "Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for " + "position tracking, but you have disabled Razer Hydra from RUIS " + "InputManager."); if(headRotationInput == HeadRotationSource.RazerHydra) Debug.LogWarning( "Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for " + "rotation tracking, but you have disabled Razer Hydra from RUIS " + "InputManager."); if(externalDriftCorrection && compass == CompassSource.RazerHydra) Debug.LogWarning( "Your " + typeof(RUISTracker) + " settings indicate that you want to use Razer Hydra for " + "yaw drift correction, but you have disabled Razer Hydra from RUIS " + "InputManager."); } if(headPositionInput == HeadPositionSource.InputTransform && !positionInput) Debug.LogError("Position tracker's Input Transform is none, you need to set it in Unity inspector!"); if(headRotationInput == HeadRotationSource.InputTransform && !rotationInput && !useOculusRiftRotation) Debug.LogError("Rotation tracker's Input Transform is none, you need to set it in Unity inspector!"); if(headPositionInput == HeadPositionSource.Kinect1 && positionJoint == RUISSkeletonManager.Joint.None) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to track position with a " + "Kinect joint, but you have left its value to None in Unity inspector!"); if( headRotationInput == HeadRotationSource.Kinect1 && rotationJoint == RUISSkeletonManager.Joint.None && !useOculusRiftRotation ) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to track rotation with a " + "Kinect joint, but you have left its value to None in Unity inspector!"); if( externalDriftCorrection && compass == CompassSource.Kinect1 && compassJoint == RUISSkeletonManager.Joint.None && !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform)) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to do yaw drift correction with a " + "Kinect joint, but you have left its value to None in Unity inspector!"); if(headPositionInput == HeadPositionSource.Kinect2 && positionJoint == RUISSkeletonManager.Joint.None) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to track position with a " + "Kinect2 joint, but you have left its value to None in Unity inspector!"); if( headRotationInput == HeadRotationSource.Kinect2 && rotationJoint == RUISSkeletonManager.Joint.None && !useOculusRiftRotation ) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to track rotation with a " + "Kinect2 joint, but you have left its value to None in Unity inspector!"); if( externalDriftCorrection && compass == CompassSource.Kinect2 && compassJoint == RUISSkeletonManager.Joint.None && !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform)) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to do yaw drift correction with a " + "Kinect2 joint, but you have left its value to None in Unity inspector!"); if( externalDriftCorrection && compass == CompassSource.InputTransform && !compassTransform && !compassIsPositionTracker && (useOculusRiftRotation || headRotationInput == HeadRotationSource.InputTransform)) Debug.LogError("Yaw drift corrector's Input Transform is none, you need to set it in Unity inspector!"); if(externalDriftCorrection && compassIsPositionTracker && headPositionInput == HeadPositionSource.None) Debug.LogError( "Position Tracker is set to None, but in 'Yaw Drift Correction' you have enabled " + "'Use Position Tracker'!"); if(isRazerBaseMobile && ( headPositionInput == HeadPositionSource.RazerHydra || headRotationInput == HeadRotationSource.RazerHydra || compass == CompassSource.RazerHydra )) { if(mobileRazerBase == RazerHydraBase.InputTransform && hydraBaseInput == null) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to track Razer Hydra base station with a " + "custom Input Transform, but you have left its value to None in Unity inspector!"); if(mobileRazerBase == RazerHydraBase.Kinect1 && hydraBaseJoint == RUISSkeletonManager.Joint.None) Debug.LogError( "Your " + typeof(RUISTracker) + " settings indicate that you want to track Razer Hydra base station with a " + "Kinect joint, but you have left its value to None in Unity inspector!"); } if(useOculusRiftRotation && headPositionInput != HeadPositionSource.OculusDK2 && ovrCameraRig != null) { DisableOculusPositionalTracking(); // OVR manager is not necessarily initialized, so lets do the above disabling later as well StartCoroutine(DelayedDisableOculusPositionalTracking()); Debug.Log( typeof(RUISTracker) + ": Position Tracker is " + headPositionInput + " and " + typeof(OVRCameraRig) + " found in a child gameObject, turning off Oculus Rift position tracking altogether. If you do not " + "want this, then remove the " + typeof(OVRCameraRig) + " component from the child object(s)."); } if(ovrCameraRig && Application.isEditor) Debug.Log(typeof(OVRCameraRig) + " script detected in a child object of this " + gameObject.name + " object. Using Oculus Rift as a Rotation Tracker. You can access other rotation " + "trackers when you remove the " + typeof(OVRCameraRig) + " component from the child object(s)."); // if(useOculusRiftRotation && inputManager) // { // if( (inputManager.enableKinect && headPositionInput == HeadPositionSource.Kinect) // || (inputManager.enableRazerHydra && headPositionInput == HeadPositionSource.RazerHydra) // || (inputManager.enablePSMove && headPositionInput == HeadPositionSource.PSMove) // || headPositionInput == HeadPositionSource.InputTransform ) // { // oculusCamController.SetNeckPosition(Vector3.zero); // oculusCamController.SetEyeCenterPosition(Vector3.zero); // Debug.Log( "Head position tracker found, setting NeckPosition and EyeCenterPosition to zero from " // + "OVRManager."); // } // } }
private void updateCalibratableDevices() { List <string> dropDownChoices = new List <string>(); string currentSelection = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection; //dropDownChoices.Add ("Select device(s)"); if (inputManager.enableKinect) { dropDownChoices.Add("Kinect floor data"); } if (inputManager.enableKinect2) { dropDownChoices.Add("Kinect 2 floor data"); } bool isPositionTrackedOculusPresent = false; // #if UNITY_EDITOR // if(UnityEditorInternal.InternalEditorUtility.HasPro()) // #endif { try { if (OVRManager.capiHmd != null) { ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; } if (OVRManager.display != null) { isPositionTrackedOculusPresent = OVRManager.display.isPresent && (ovrHmdVersion == Ovr.HmdType.DK2 || ovrHmdVersion == Ovr.HmdType.Other); } } catch (UnityException e) { Debug.LogError(e); } } if (inputManager.enableKinect && inputManager.enableKinect2) { dropDownChoices.Add("Kinect - Kinect2"); } if (inputManager.enableKinect && inputManager.enablePSMove) { dropDownChoices.Add("Kinect - PSMove"); } if (inputManager.enableKinect2 && inputManager.enablePSMove) { dropDownChoices.Add("Kinect 2 - PSMove"); } if (isPositionTrackedOculusPresent && inputManager.enableKinect2) { dropDownChoices.Add("Kinect 2 - Oculus DK2"); } if (isPositionTrackedOculusPresent && inputManager.enableKinect) { dropDownChoices.Add("Kinect - Oculus DK2"); } if (isPositionTrackedOculusPresent && inputManager.enablePSMove) { dropDownChoices.Add("PSMove - Oculus DK2"); } if (dropDownChoices.Count == 0) { dropDownChoices.Add("Select device(s)"); } this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().items = dropDownChoices; if (!dropDownChoices.Contains(currentSelection)) { this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Buttons/Dropdown - Calibration Devices").GetComponent <UIPopupList>().selection = dropDownChoices[0]; } }
private void handleInfotexts() { GameObject infotext_Changes_saved = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes saved").gameObject; GameObject infotext_Changes_are_not_saved_in_free_version = this.transform.Find( "NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes are not saved in free version").gameObject; GameObject infotext_Changes_not_saved_yet = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Saving/Label - Changes not saved yet").gameObject; GameObject infotext_Rift_not_Detected = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Rift/Label - Rift not detected").gameObject; GameObject infotext_Oculus_DK1_detected = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Rift/Label - Oculus DK1 detected").gameObject; GameObject infotext_Oculus_DK2_detected = this.transform.Find("NGUIControls/Panel/selectAndConfigureDevices/Infotexts/Rift/Label - Oculus DK2 detected").gameObject; bool isRiftConnected = false; // #if UNITY_EDITOR // if(UnityEditorInternal.InternalEditorUtility.HasPro()) // #endif { try { if (OVRManager.display != null) { isRiftConnected = OVRManager.display.isPresent; } if (OVRManager.capiHmd != null) { ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; } } catch (UnityException e) { Debug.LogError(e); } } if (isRiftConnected && ovrHmdVersion == Ovr.HmdType.DK1) { infotext_Rift_not_Detected.SetActive(false); infotext_Oculus_DK1_detected.SetActive(true); infotext_Oculus_DK2_detected.SetActive(false); } else if (isRiftConnected && (ovrHmdVersion == Ovr.HmdType.DK2 || ovrHmdVersion == Ovr.HmdType.Other)) { infotext_Rift_not_Detected.SetActive(false); infotext_Oculus_DK2_detected.SetActive(true); infotext_Oculus_DK1_detected.SetActive(false); } else { infotext_Rift_not_Detected.SetActive(true); infotext_Oculus_DK1_detected.SetActive(false); infotext_Oculus_DK2_detected.SetActive(false); } if (!XmlImportExport.XmlHandlingFunctionalityAvailable()) { infotext_Changes_are_not_saved_in_free_version.SetActive(true); infotext_Changes_saved.SetActive(false); infotext_Changes_not_saved_yet.SetActive(false); } else { infotext_Changes_are_not_saved_in_free_version.SetActive(false); if (originalPSMoveIP == inputManager.PSMoveIP && originalPSMovePort == inputManager.PSMovePort && originalEnablePSMove == inputManager.enablePSMove && originalEnableKinect == inputManager.enableKinect && originalEnableKinect2 == inputManager.enableKinect2 && originalEnableJumpGesture == inputManager.jumpGestureEnabled && originalEnableHydra == inputManager.enableRazerHydra && originalKinectDriftCorrection == inputManager.kinectDriftCorrectionPreferred) { infotext_Changes_saved.SetActive(true); infotext_Changes_not_saved_yet.SetActive(false); } else { infotext_Changes_not_saved_yet.SetActive(true); infotext_Changes_saved.SetActive(false); } } }
void Awake() { if (!scriptEnabled) { return; } inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; bool kinect2 = false; bool kinect = false; bool psmove = false; bool razer = false; bool oculusDK2 = false; bool isRiftConnected = false; //#if UNITY_EDITOR //if(UnityEditorInternal.InternalEditorUtility.HasPro()) //#endif { try { // Find out if an Oculus HMD is connected if (OVRManager.display != null) { isRiftConnected = OVRManager.display.isPresent; } // Find out the Oculus HMD version if (OVRManager.capiHmd != null) { ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; } } catch (UnityException e) { Debug.LogError(e); } } if (inputManager) { if (isRiftConnected && (ovrHmdVersion == Ovr.HmdType.DK2 || ovrHmdVersion == Ovr.HmdType.Other)) { oculusDK2 = true; } kinect2 = inputManager.enableKinect2; kinect = inputManager.enableKinect; psmove = inputManager.enablePSMove; razer = inputManager.enableRazerHydra; int trackerCount = 0; RUISTracker closestMatch = null; int currentMatchScore = 0; RUISHeadTrackerAssigner[] assigners = FindObjectsOfType(typeof(RUISHeadTrackerAssigner)) as RUISHeadTrackerAssigner[]; if (!allowMultipleAssigners && assigners.Length > 1) { Debug.LogError("Multiple active RUISHeadTrackerAssigner scripts found while 'Allow Multiple Assigners' is false: " + "Disabling all headtrackers and their child objects that are listed in the RUISHeadTrackerAssigner " + "component of '" + gameObject.name + "' object."); for (int i = 0; i < headTrackers.Capacity; ++i) { if (headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { headTrackers[i].gameObject.SetActive(false); } } return; } foreach (RUISTracker trackerScript in headTrackers) { if (trackerScript && trackerScript.gameObject.activeInHierarchy) { ++trackerCount; int foundTrackerScore = 0; // Give score to found head trackers if (oculusDK2 && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.OculusDK2) { foundTrackerScore = 7; print(trackerScript); } else if (psmove && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.PSMove) { foundTrackerScore = 6; } else if (razer && trackerScript.isRazerBaseMobile && // Legacy: Mobile Hydra Base (custom tracker) trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && trackerScript.mobileRazerBase == RUISTracker.RazerHydraBase.InputTransform) { foundTrackerScore = 5; } else if (kinect2 && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.Kinect2) { foundTrackerScore = 4; } else if (kinect && razer && trackerScript.isRazerBaseMobile && // Legacy: Mobile Hydra Base (Kinect) trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && trackerScript.mobileRazerBase == RUISTracker.RazerHydraBase.Kinect1) { foundTrackerScore = 3; } else if (kinect && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.Kinect1) { foundTrackerScore = 2; } else if (razer && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && // Plain ol' Razer Hydra !trackerScript.isRazerBaseMobile) { foundTrackerScore = 1; } // Assign new best head tracker candidate if it is better than the previously found if (currentMatchScore < foundTrackerScore) { closestMatch = trackerScript; currentMatchScore = foundTrackerScore; } } } if (trackerCount == 0 && Application.isEditor) { Debug.LogError("No active GameObjects with RUISTracker script found from headTrackers list!"); } string positionTracker = "<None>"; string logString = ""; string names = ""; RUISCamera ruisCamera = null; if (closestMatch == null) { // Disable all but the first active head tracker from the headTrackers list logString = "Could not find a suitable head tracker with regard to " + "enabled devices in RUISInputManager!"; bool disabling = false; int leftEnabledIndex = -1; for (int i = 0; i < headTrackers.Capacity; ++i) { if (headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { if (disabling) { if (names.Length > 0) { names = names + ", "; } names = names + headTrackers[i].gameObject.name; headTrackers[i].gameObject.SetActive(false); } else { leftEnabledIndex = i; closestMatch = headTrackers[leftEnabledIndex]; positionTracker = headTrackers[leftEnabledIndex].gameObject.name; disabling = true; } } } if (leftEnabledIndex >= 0) { logString = logString + " Choosing the first head tracker in the list. Using " + positionTracker + " for tracking head position"; if (names.Length > 0) { logString = logString + ", and disabling the following: " + names; } logString = logString + ". This choice was made using a pre-selected list of " + "head trackers."; ruisCamera = headTrackers[leftEnabledIndex].gameObject.GetComponentInChildren <RUISCamera>(); } Debug.LogError(logString); } else { // Disable all but the closest match head tracker from the headTrackers list for (int i = 0; i < headTrackers.Capacity; ++i) { if (headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { if (headTrackers[i] != closestMatch) { if (names.Length > 0) { names = names + ", "; } names = names + headTrackers[i].gameObject.name; headTrackers[i].gameObject.SetActive(false); } else { positionTracker = headTrackers[i].gameObject.name; } } } logString = "Found the best head tracker with regard to enabled devices in " + "RUISInputManager! Using " + positionTracker + " for tracking head position"; if (names.Length > 0) { logString = logString + ", and disabling the following: " + names; } Debug.Log(logString + ". This choice was made using a pre-selected list of head trackers."); ruisCamera = closestMatch.gameObject.GetComponentInChildren <RUISCamera>(); if (changePivotIfNoKinect && psmove && !kinect && !kinect2 && closestMatch.headPositionInput == RUISTracker.HeadPositionSource.PSMove) { RUISCharacterController characterController = gameObject.GetComponentInChildren <RUISCharacterController>(); if (characterController != null && characterController.characterPivotType != RUISCharacterController.CharacterPivotType.MoveController) { characterController.characterPivotType = RUISCharacterController.CharacterPivotType.MoveController; characterController.moveControllerId = closestMatch.positionPSMoveID; Debug.Log("PS Move enabled and Kinect disabled. Setting " + characterController.name + "'s CharacterCamera Pivot as PS Move controller #" + closestMatch.positionPSMoveID + ". PS Move position offset for this pivot is " + characterController.psmoveOffset); } } } if (ruisCamera) { if (display == null) { Debug.LogWarning("No RUISDisplay attached to the RUISHeadTrackerAssigner script!"); RUISDisplay[] displays = FindObjectsOfType(typeof(RUISDisplay)) as RUISDisplay[]; for (int i = 0; i < displays.Length; ++i) { if (displays[i].linkedCamera == null) { Debug.LogWarning("Assigned RUISCamera component from the child of " + positionTracker + " to render on " + displays[i].gameObject.name + " because that " + "RUISDisplay component's RUISCamera field was empty."); displays[i].linkedCamera = ruisCamera; break; } } } else { if (display.linkedCamera == null) { Debug.Log("Assigned RUISCamera component from the child of " + positionTracker + " to render on " + display.gameObject.name); display.linkedCamera = ruisCamera; } else { Debug.LogWarning("RUISDisplay " + display.gameObject.name + " is already connected with a " + "RUISCamera object! Leave the RUISCamera field empty in your RUISDisplay " + "component if you want RUISHeadTrackerAssigner script to automatically " + "assign a RUISCamera to your RUISDisplay."); } } } else { if (closestMatch) { Debug.LogError(positionTracker + " did not have a child with RUISCamera component, " + "and therefore it is not used to draw on any of the displays in " + "DisplayManager."); } } // If we are using Razer with a static base for head tracking, then apply onlyRazerOffset // on the parent objects of the Razer head tracker and the hand-held Razer if (closestMatch != null && razer && closestMatch.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && !closestMatch.isRazerBaseMobile) { // The parent object of the Razer head tracker must not have RUISCharacterConroller, // because that script will modify the object's position if (closestMatch.transform.parent != null && closestMatch.transform.parent.GetComponent <RUISCharacterController>() == null && (onlyRazerOffset.x != 0 || onlyRazerOffset.y != 0 || onlyRazerOffset.z != 0)) { string razerWandOffsetInfo = ""; closestMatch.transform.parent.localPosition += onlyRazerOffset; if (razerWandParent != null) { razerWandParent.localPosition += onlyRazerOffset; razerWandOffsetInfo = " and " + razerWandParent.gameObject.name + " (parent of hand-held Razer " + "Hydra)"; } Debug.Log("Applying offset of " + onlyRazerOffset + " to " + closestMatch.transform.parent.gameObject.name + " (parent of Razer Hydra head tracker)" + razerWandOffsetInfo + "."); } } // If no Razer, Kinect, or PS Move is available, then apply onlyMouseOffset // on the parent object of the head tracker that is left enabled // if( closestMatch != null && !razer && !kinect && !psmove) // { // // The parent object of the Razer head tracker must not have RUISCharacterConroller, // // because that script will modify the object's position // if( closestMatch.transform.parent != null // && closestMatch.transform.parent.GetComponent<RUISCharacterController>() == null // && (onlyMouseOffset.x != 0 || onlyMouseOffset.y != 0 || onlyMouseOffset.z != 0) ) // { // closestMatch.transform.parent.localPosition += onlyMouseOffset; // Debug.Log( "Applying offset of " + onlyMouseOffset + " to " // + closestMatch.transform.parent.gameObject.name + " (parent of assigned head tracker)."); // } // } // *** TODO: Below is slightly hacky // Read inputConfig.xml to see if Kinect yaw drift correction for Oculus Rift should be enabled if (closestMatch != null && closestMatch.useOculusRiftRotation && applyKinectDriftCorrectionPreference) { if (inputManager.kinectDriftCorrectionPreferred) { // Preference is to use Kinect for drift correction (if PS Move is not used for head tracking) switch (closestMatch.headPositionInput) { case RUISTracker.HeadPositionSource.Kinect1: if (!psmove && kinect) { closestMatch.externalDriftCorrection = true; closestMatch.compass = RUISTracker.CompassSource.Kinect1; } break; case RUISTracker.HeadPositionSource.RazerHydra: if (!psmove && kinect && razer) { if (closestMatch.isRazerBaseMobile) { closestMatch.externalDriftCorrection = true; closestMatch.compass = RUISTracker.CompassSource.Kinect1; } } break; } } else { // Preference is NOT to use Kinect for drift correction if (closestMatch.headPositionInput == RUISTracker.HeadPositionSource.Kinect1 && !psmove && kinect) { closestMatch.externalDriftCorrection = false; } } } } }
void Start() { colliding = false; grounded = false; // Second substitution, because RUISKinectAndMecanimCombiner might have already erased the original one and re-created it skeletonController = gameObject.GetComponentInChildren<RUISSkeletonController>(); if(skeletonController) { bodyParts.Add(skeletonController.leftFoot); bodyParts.Add(skeletonController.rightFoot); kinectPlayerId = skeletonController.playerId; bodyTrackingDeviceID = skeletonController.bodyTrackingDeviceID; } else { Debug.LogError( "RUISCharacterController script in game object '" + gameObject.name + "' did not find RUISSkeletonController component from it's child objects!"); } coordinateSystem = FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem; if(stabilizingCollider) { colliderComponent = stabilizingCollider.gameObject.GetComponent<Collider>(); if(colliderComponent) { if( characterPivotType == CharacterPivotType.KinectHead || characterPivotType == CharacterPivotType.KinectTorso) { if(coordinateSystem && inputManager.enableKinect && !coordinateSystem.setKinectOriginToFloor) Debug.LogWarning("It is best to enable 'setKinectOriginToFloor' from RUISCoordinateSystem " + "when using Kinect and RUISCharacterController script."); } if(colliderComponent.material) originalMaterial = colliderComponent.material; else { colliderComponent.material = new PhysicMaterial(); originalMaterial = colliderComponent.material; } if(dynamicMaterial == null) { dynamicMaterial = new PhysicMaterial(); dynamicMaterial.dynamicFriction = 0; dynamicMaterial.staticFriction = 0; dynamicMaterial.frictionCombine = PhysicMaterialCombine.Minimum; if(colliderComponent.material) { dynamicMaterial.bounceCombine = originalMaterial.bounceCombine; dynamicMaterial.bounciness = originalMaterial.bounciness; // dynamicMaterial.staticFriction2 = originalMaterial.staticFriction2; // dynamicMaterial.dynamicFriction2 = originalMaterial.dynamicFriction2; // dynamicMaterial.frictionDirection2 = originalMaterial.frictionDirection2; } } } } if(( characterPivotType == CharacterPivotType.KinectHead || characterPivotType == CharacterPivotType.KinectTorso) && (skeletonController && skeletonController.playerId != kinectPlayerId)) Debug.LogError( "The 'Kinect Player Id' variable in RUISCharacterController script in gameObject '" + gameObject.name + "is different from the Kinect Player Id of the RUISSkeletonController script (located in child " + "object '" + skeletonController.gameObject.name + "). Make sure that these two values are " + "the same."); //#if UNITY_EDITOR //if(UnityEditorInternal.InternalEditorUtility.HasPro()) //#endif { try { bool isRiftConnected = false; if(OVRManager.display != null) isRiftConnected = OVRManager.display.isPresent; if(OVRManager.capiHmd != null) ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; if(useOculusPositionalTracking && ovrHmdVersion == Ovr.HmdType.DK1 || ovrHmdVersion == Ovr.HmdType.DKHD || ovrHmdVersion == Ovr.HmdType.None) { Debug.LogError("Can't use Oculus Rift's tracked position as a pivot with Oculus Rift " + ovrHmdVersion); useOculusPositionalTracking = false; } if(useOculusPositionalTracking && !isRiftConnected) { Debug.LogError("Can't use Oculus Rift's tracked position as a pivot because Oculus Rift is not connected."); useOculusPositionalTracking = false; } } catch(UnityException e) { useOculusPositionalTracking = false; Debug.LogError(e); } } if(GetComponentInChildren<RUISKinectAndMecanimCombiner>()) kinectAndMecanimCombinerExists = true; previousPosition = transform.position; }
void Awake() { if(!scriptEnabled) return; inputManager = FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager; bool kinect2 = false; bool kinect = false; bool psmove = false; bool razer = false; bool oculusDK2 = false; bool isRiftConnected = false; //#if UNITY_EDITOR //if(UnityEditorInternal.InternalEditorUtility.HasPro()) //#endif { try { // Find out if an Oculus HMD is connected if(OVRManager.display != null) isRiftConnected = OVRManager.display.isPresent; // Find out the Oculus HMD version if(OVRManager.capiHmd != null) ovrHmdVersion = OVRManager.capiHmd.GetDesc().Type; } catch(UnityException e) { Debug.LogError(e); } } if(inputManager) { if(isRiftConnected && (ovrHmdVersion == Ovr.HmdType.DK2 || ovrHmdVersion == Ovr.HmdType.Other)) oculusDK2 = true; kinect2 = inputManager.enableKinect2; kinect = inputManager.enableKinect; psmove = inputManager.enablePSMove; razer = inputManager.enableRazerHydra; int trackerCount = 0; RUISTracker closestMatch = null; int currentMatchScore = 0; RUISHeadTrackerAssigner[] assigners = FindObjectsOfType(typeof(RUISHeadTrackerAssigner)) as RUISHeadTrackerAssigner[]; if(!allowMultipleAssigners && assigners.Length > 1) { Debug.LogError( "Multiple active RUISHeadTrackerAssigner scripts found while 'Allow Multiple Assigners' is false: " + "Disabling all headtrackers and their child objects that are listed in the RUISHeadTrackerAssigner " + "component of '" + gameObject.name + "' object."); for(int i = 0; i < headTrackers.Capacity; ++i) { if(headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) headTrackers[i].gameObject.SetActive(false); } return; } foreach(RUISTracker trackerScript in headTrackers) { if(trackerScript && trackerScript.gameObject.activeInHierarchy) { ++trackerCount; int foundTrackerScore = 0; // Give score to found head trackers if(oculusDK2 && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.OculusDK2) { foundTrackerScore = 7; print (trackerScript); } else if(psmove && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.PSMove) { foundTrackerScore = 6; } else if( razer && trackerScript.isRazerBaseMobile // Legacy: Mobile Hydra Base (custom tracker) && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && trackerScript.mobileRazerBase == RUISTracker.RazerHydraBase.InputTransform ) { foundTrackerScore = 5; } else if(kinect2 && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.Kinect2) { foundTrackerScore = 4; } else if( kinect && razer && trackerScript.isRazerBaseMobile // Legacy: Mobile Hydra Base (Kinect) && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && trackerScript.mobileRazerBase == RUISTracker.RazerHydraBase.Kinect1 ) { foundTrackerScore = 3; } else if(kinect && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.Kinect1) { foundTrackerScore = 2; } else if( razer && trackerScript.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra // Plain ol' Razer Hydra && !trackerScript.isRazerBaseMobile ) { foundTrackerScore = 1; } // Assign new best head tracker candidate if it is better than the previously found if(currentMatchScore < foundTrackerScore) { closestMatch = trackerScript; currentMatchScore = foundTrackerScore; } } } if(trackerCount == 0 && Application.isEditor) Debug.LogError("No active GameObjects with RUISTracker script found from headTrackers list!"); string positionTracker = "<None>"; string logString = ""; string names = ""; RUISCamera ruisCamera = null; if(closestMatch == null) { // Disable all but the first active head tracker from the headTrackers list logString = "Could not find a suitable head tracker with regard to " + "enabled devices in RUISInputManager!"; bool disabling = false; int leftEnabledIndex = -1; for(int i = 0; i < headTrackers.Capacity; ++i) { if(headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { if(disabling) { if(names.Length > 0) names = names + ", "; names = names + headTrackers[i].gameObject.name; headTrackers[i].gameObject.SetActive(false); } else { leftEnabledIndex = i; closestMatch = headTrackers[leftEnabledIndex]; positionTracker = headTrackers[leftEnabledIndex].gameObject.name; disabling = true; } } } if(leftEnabledIndex >= 0) { logString = logString + " Choosing the first head tracker in the list. Using " + positionTracker + " for tracking head position"; if(names.Length > 0) logString = logString + ", and disabling the following: " + names; logString = logString + ". This choice was made using a pre-selected list of " + "head trackers."; ruisCamera = headTrackers[leftEnabledIndex].gameObject.GetComponentInChildren<RUISCamera>(); } Debug.LogError(logString); } else { // Disable all but the closest match head tracker from the headTrackers list for(int i = 0; i < headTrackers.Capacity; ++i) { if(headTrackers[i] && headTrackers[i].gameObject.activeInHierarchy) { if(headTrackers[i] != closestMatch) { if(names.Length > 0) names = names + ", "; names = names + headTrackers[i].gameObject.name; headTrackers[i].gameObject.SetActive(false); } else { positionTracker = headTrackers[i].gameObject.name; } } } logString = "Found the best head tracker with regard to enabled devices in " + "RUISInputManager! Using " + positionTracker + " for tracking head position"; if(names.Length > 0) logString = logString + ", and disabling the following: " + names; Debug.Log(logString + ". This choice was made using a pre-selected list of head trackers."); ruisCamera = closestMatch.gameObject.GetComponentInChildren<RUISCamera>(); if( changePivotIfNoKinect && psmove && !kinect && !kinect2 && closestMatch.headPositionInput == RUISTracker.HeadPositionSource.PSMove ) { RUISCharacterController characterController = gameObject.GetComponentInChildren<RUISCharacterController>(); if( characterController != null && characterController.characterPivotType != RUISCharacterController.CharacterPivotType.MoveController ) { characterController.characterPivotType = RUISCharacterController.CharacterPivotType.MoveController; characterController.moveControllerId = closestMatch.positionPSMoveID; Debug.Log( "PS Move enabled and Kinect disabled. Setting " + characterController.name + "'s Character Pivot as PS Move controller #" + closestMatch.positionPSMoveID + ". PS Move position offset for this pivot is " + characterController.psmoveOffset); } } } if(ruisCamera) { if(display == null) { Debug.LogWarning( "No RUISDisplay attached to the RUISHeadTrackerAssigner script!"); RUISDisplay[] displays = FindObjectsOfType(typeof(RUISDisplay)) as RUISDisplay[]; for(int i = 0; i < displays.Length; ++i) { if(displays[i].linkedCamera == null) { Debug.LogWarning( "Assigned RUISCamera component from the child of " + positionTracker + " to render on " + displays[i].gameObject.name + " because that " + "RUISDisplay component's RUISCamera field was empty."); displays[i].linkedCamera = ruisCamera; break; } } } else { if(display.linkedCamera == null) { Debug.Log( "Assigned RUISCamera component from the child of " + positionTracker + " to render on " + display.gameObject.name ); display.linkedCamera = ruisCamera; } else Debug.LogWarning( "RUISDisplay " + display.gameObject.name + " is already connected with a " + "RUISCamera object! Leave the RUISCamera field empty in your RUISDisplay " + "component if you want RUISHeadTrackerAssigner script to automatically " + "assign a RUISCamera to your RUISDisplay."); } } else { if(closestMatch) Debug.LogError( positionTracker + " did not have a child with RUISCamera component, " + "and therefore it is not used to draw on any of the displays in " + "DisplayManager."); } // If we are using Razer with a static base for head tracking, then apply onlyRazerOffset // on the parent objects of the Razer head tracker and the hand-held Razer if( closestMatch != null && razer && closestMatch.headPositionInput == RUISTracker.HeadPositionSource.RazerHydra && !closestMatch.isRazerBaseMobile ) { // The parent object of the Razer head tracker must not have RUISCharacterConroller, // because that script will modify the object's position if( closestMatch.transform.parent != null && closestMatch.transform.parent.GetComponent<RUISCharacterController>() == null && (onlyRazerOffset.x != 0 || onlyRazerOffset.y != 0 || onlyRazerOffset.z != 0) ) { string razerWandOffsetInfo = ""; closestMatch.transform.parent.localPosition += onlyRazerOffset; if(razerWandParent != null) { razerWandParent.localPosition += onlyRazerOffset; razerWandOffsetInfo = " and " + razerWandParent.gameObject.name + " (parent of hand-held Razer " + "Hydra)"; } Debug.Log( "Applying offset of " + onlyRazerOffset + " to " + closestMatch.transform.parent.gameObject.name + " (parent of Razer Hydra head tracker)" + razerWandOffsetInfo + "." ); } } // If no Razer, Kinect, or PS Move is available, then apply onlyMouseOffset // on the parent object of the head tracker that is left enabled // if( closestMatch != null && !razer && !kinect && !psmove) // { // // The parent object of the Razer head tracker must not have RUISCharacterConroller, // // because that script will modify the object's position // if( closestMatch.transform.parent != null // && closestMatch.transform.parent.GetComponent<RUISCharacterController>() == null // && (onlyMouseOffset.x != 0 || onlyMouseOffset.y != 0 || onlyMouseOffset.z != 0) ) // { // closestMatch.transform.parent.localPosition += onlyMouseOffset; // Debug.Log( "Applying offset of " + onlyMouseOffset + " to " // + closestMatch.transform.parent.gameObject.name + " (parent of assigned head tracker)."); // } // } // *** TODO: Below is slightly hacky // Read inputConfig.xml to see if Kinect yaw drift correction for Oculus Rift should be enabled if( closestMatch != null && closestMatch.useOculusRiftRotation && applyKinectDriftCorrectionPreference) { if(inputManager.kinectDriftCorrectionPreferred) { // Preference is to use Kinect for drift correction (if PS Move is not used for head tracking) switch(closestMatch.headPositionInput) { case RUISTracker.HeadPositionSource.Kinect1: if(!psmove && kinect) { closestMatch.externalDriftCorrection = true; closestMatch.compass = RUISTracker.CompassSource.Kinect1; } break; case RUISTracker.HeadPositionSource.RazerHydra: if(!psmove && kinect && razer) { if(closestMatch.isRazerBaseMobile) { closestMatch.externalDriftCorrection = true; closestMatch.compass = RUISTracker.CompassSource.Kinect1; } } break; } } else { // Preference is NOT to use Kinect for drift correction if( closestMatch.headPositionInput == RUISTracker.HeadPositionSource.Kinect1 && !psmove && kinect ) closestMatch.externalDriftCorrection = false; } } } }