Exemple #1
0
        public static Transform AddViveTracker(HumanoidControl humanoid, int trackerId = -1)
        {
            GameObject trackerPrefab = Resources.Load(resourceName) as GameObject;
            GameObject trackerObject = (trackerPrefab == null) ? new GameObject(resourceName) : Object.Instantiate(trackerPrefab);

            trackerObject.name = resourceName;

            ViveTrackerComponent trackerComponent = trackerObject.GetComponent <ViveTrackerComponent>();

            if (trackerComponent == null)
            {
                trackerComponent = trackerObject.AddComponent <ViveTrackerComponent>();
            }

            if (trackerId != -1)
            {
                trackerComponent.trackerId = trackerId;
            }
#if hSTEAMVR
            trackerObject.transform.parent = humanoid.steam.trackerTransform;

            trackerComponent.StartComponent(humanoid.steam.trackerTransform);
#elif hOPENVR
            trackerObject.transform.parent = humanoid.openVR.trackerTransform;

            trackerComponent.StartComponent(humanoid.openVR.trackerTransform);
#endif
            return(trackerObject.transform);
        }
        public override void Start(HumanoidControl _humanoid, Transform targetTransform)
        {
            base.Start(_humanoid, targetTransform);
#if hSTEAMVR
            tracker = hipsTarget.humanoid.steam;
#elif hOPENVR
            tracker = hipsTarget.humanoid.openVR;
#endif

            if (sensorTransform != null)
            {
                viveTracker = sensorTransform.GetComponent <ViveTrackerComponent>();
                if (viveTracker != null)
                {
                    viveTracker.StartComponent(tracker.trackerTransform);
                }
            }
        }