From 14d30d28e37e160c12d9af125d5f3cbbdc4bd3b1 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 10 May 2023 10:26:50 +0200 Subject: [PATCH] Fix error when UnityXR is not enabled --- .../Scripts/HumanoidControl.cs | 76 ++++++++++--------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/Runtime/HumanoidControl/Scripts/HumanoidControl.cs b/Runtime/HumanoidControl/Scripts/HumanoidControl.cs index 1d86e01..e9c6e7d 100644 --- a/Runtime/HumanoidControl/Scripts/HumanoidControl.cs +++ b/Runtime/HumanoidControl/Scripts/HumanoidControl.cs @@ -453,8 +453,10 @@ namespace Passer.Humanoid { AddCharacterColliders(); avatarNeckHeight = GetAvatarNeckHeight(); +#if pUNITYXR if (headTarget.unityXR != null) headTarget.unityXR.UpdateSensorLocation(); +#endif switch (scaling) { case ScalingType.SetHeightToAvatar: @@ -653,9 +655,9 @@ namespace Passer.Humanoid { return 0; } - #endregion +#endregion - #region Targets +#region Targets protected void NewTargetComponents() { #if pCEREBELLUM if (cerebellum == null) @@ -962,9 +964,9 @@ namespace Passer.Humanoid { }; } - #endregion +#endregion - #region Trackers +#region Trackers /// Use game controller input public bool gameControllerEnabled = true; @@ -1311,9 +1313,9 @@ namespace Passer.Humanoid { tracker.AdjustTracking(translation, rotation); } - #endregion +#endregion - #region Configuration +#region Configuration /// /// Scans the humanoid to retrieve all bones /// @@ -1326,9 +1328,9 @@ namespace Passer.Humanoid { leftFootTarget.RetrieveBones(); rightFootTarget.RetrieveBones(); } - #endregion +#endregion - #region Update +#region Update protected virtual void Update() { Controllers.Clear(); @@ -1363,9 +1365,9 @@ namespace Passer.Humanoid { Controllers.EndFrame(); } - #endregion +#endregion - #region Stop +#region Stop public void OnApplicationQuit() { #if hLEAP leap.StopTracker(); @@ -1389,11 +1391,11 @@ namespace Passer.Humanoid { optitrack.StopTracker(); #endif } - #endregion +#endregion - #region Destroy +#region Destroy - #endregion +#endregion public Vector3 up { get { @@ -1438,7 +1440,7 @@ namespace Passer.Humanoid { } } - #region Calibration +#region Calibration public void SetStartPosition() { } @@ -1467,9 +1469,9 @@ namespace Passer.Humanoid { } } - #endregion +#endregion - #region Pose +#region Pose protected virtual void UpdatePose() { if (pose != null) { @@ -1478,7 +1480,7 @@ namespace Passer.Humanoid { } } - #region Pose Event +#region Pose Event public delegate void OnHumanoidPose(HumanoidPose pose); public event OnHumanoidPose onHumanoidPose; @@ -1539,11 +1541,11 @@ namespace Passer.Humanoid { } } - #endregion +#endregion - #endregion +#endregion - #region Movement +#region Movement /// /// maximum forward speed in units(meters)/second @@ -1588,7 +1590,7 @@ namespace Passer.Humanoid { protected Vector3 inputMovement = Vector3.zero; - #region Input/API +#region Input/API /// /// maximum forward speed in units(meters)/second @@ -1809,9 +1811,9 @@ namespace Passer.Humanoid { } - #endregion +#endregion - #region Checks +#region Checks [HideInInspector] public Vector3 targetVelocity; @@ -1924,9 +1926,9 @@ namespace Passer.Humanoid { return distance * elapsedTime * elapsedTime + start; } - #endregion +#endregion - #region Collisions +#region Collisions public bool triggerEntered; public bool collided; @@ -2099,9 +2101,9 @@ namespace Passer.Humanoid { ); } - #endregion +#endregion - #region Ground +#region Ground /// /// The ground Transform on which the pawn is standing @@ -2262,9 +2264,9 @@ namespace Passer.Humanoid { lastGroundAngle = ground.eulerAngles.y; } - #endregion +#endregion - #region Body Pull +#region Body Pull protected virtual void CheckBodyPull() { if (!bodyPull) @@ -2303,7 +2305,7 @@ namespace Passer.Humanoid { transform.Translate(translation, Space.World); } - #endregion +#endregion [HideInInspector] private float lastTime; @@ -2342,7 +2344,7 @@ namespace Passer.Humanoid { lastHeadDirection = headTarget.neck.target.transform.eulerAngles.y; } - #region Animation +#region Animation private void PostAnimationCorrection() { @@ -2393,7 +2395,7 @@ namespace Passer.Humanoid { targetsRig.SetTrigger(parameterName); } - #endregion +#endregion [HideInInspector] private float lastLocalHipY; @@ -2414,7 +2416,7 @@ namespace Passer.Humanoid { lastLocalHipY = localHipY; } - #endregion Movement +#endregion Movement /// Gets the Real World GameObject for this Humanoid /// The root transform of the humanoid @@ -2482,7 +2484,7 @@ namespace Passer.Humanoid { // return footBase; //} - #region Networking +#region Networking /// Is true when this is a remote pawn /// Remote pawns are not controlled locally, but are controlled from another computer. @@ -2495,9 +2497,9 @@ namespace Passer.Humanoid { /// The local Id of this humanoid public int id = -1; - #endregion +#endregion - #region Humanoid store +#region Humanoid store private static HumanoidControl[] _allHumanoids = new HumanoidControl[0]; @@ -2604,7 +2606,7 @@ namespace Passer.Humanoid { screenPosition.y > 0 && screenPosition.y < camera.pixelHeight); } - #endregion +#endregion } }