How do I switch heads with different tracking pose settings in the same scene?
If you created 2 or more heads with different tracking pose settings, the head will use the wrong pose data when they are switched without activating one head and deactivating the other heads.
Follow the steps below to avoid this problem.
There are two ways listed below on how to find the head in the same scene. These take advantage of the style of the tracking origin, TrackingUniverseSeated and TrackingUniverseStanding to switch two heads. Use the public flag HowToFindHead of ChooseDoF to select which find method you want to use.
public class ChooseDoF : MonoBehaviour { public ETrackingUniverseOrigin trackingSpace = ETrackingUniverseOrigin.TrackingUniverseSeated; public bool HowToFindHead = false; void OnEnable() { if (HowToFindHead) method1(); else method2(); } // For method 1, it makes use of the Transform function to find the head you would like to take. void method1() { #if UNITY_5_5_OR_NEWER // Global find GameObject body1 = transform.root.Find("Body1").gameObject; GameObject body2 = transform.root.Find("Body2").gameObject; #else // Children find GameObject body1 = transform.Find("Body1").gameObject; GameObject body2 = transform.FindChild("Body2").gameObject; #endif if (trackingSpace == ETrackingUniverseOrigin.TrackingUniverseSeated) body1.SetActive(true); else body2.SetActive(true); } // For method 2, it traverses the component list to find the head you would like to take. void method2() { // Children find var list = GetComponentsInChildren<WaveVR_Render>(true); foreach (WaveVR_Render render in list) { var obj = render.transform.parent.gameObject; if (trackingSpace == ETrackingUniverseOrigin.TrackingUniverseSeated) { if (obj.name == "Body1") { obj.SetActive(true); break; } } else { if (obj.name == "Body2") { obj.SetActive(true); break; } } } } }
Found this article helpful?
Yes
No
Thank You!