diff --git a/Assets/Scripts/CLOiSimPlugins/Modules/LiftControl.cs b/Assets/Scripts/CLOiSimPlugins/Modules/LiftControl.cs index 318f1063..89206e1e 100644 --- a/Assets/Scripts/CLOiSimPlugins/Modules/LiftControl.cs +++ b/Assets/Scripts/CLOiSimPlugins/Modules/LiftControl.cs @@ -32,12 +32,11 @@ public class LiftControl : MonoBehaviour void Awake() { rootModel = Main.WorldRoot; + rootModelTransform = rootModel.transform; } void Start() { - rootModelTransform = rootModel.transform; - lift.SetTarget(transform); lift.SetInitialPose(transform.localPosition); lift.SetMovingType(Actuator.MovingType.SmoothDamp); @@ -58,12 +57,12 @@ public void SetFinishedEventListener(UnityAction call) private void FindFloorRegionInLift() { - var colliders = transform.GetComponentsInChildren(); - foreach (var collider in colliders) + var collisions = transform.GetComponentsInChildren(); + foreach (var collision in collisions) { - if (collider.name.Equals(floorColliderName)) + if (collision.name.Equals(floorColliderName)) { - floorCollider = collider; + floorCollider = collision.GetComponentInChildren(); floorCollider.convex = false; } } @@ -98,7 +97,6 @@ private void DetectObjectsToLiftAndLiftIt() if (floorCollider != null && floorCollider.bounds.Contains(topModelPosition)) { hashsetLiftingObjects.Add(topModel); - topModel.transform.SetParent(transform, true); } } @@ -108,9 +106,9 @@ private void DetectObjectsToLiftAndLiftIt() private void DropLiftedObjects() { // Unlink parenting between lifted objects if arrived at the target floor. - foreach (var obj in hashsetLiftingObjects) + if (rootModelTransform != null) { - if (rootModelTransform != null) + foreach (var obj in hashsetLiftingObjects) { obj.transform.SetParent(rootModelTransform, true); } @@ -129,15 +127,30 @@ public void MoveTo(in float targetHeight) } private IEnumerator DoLifting() - {; + { var waitForEOF = new WaitForEndOfFrame(); - + const float NEW_POSE_MARGIN = 0.005f; do { lift.Drive(); + foreach (var obj in hashsetLiftingObjects) + { + // find root articulation body and teleport the body following as + var articulationBodies = obj.GetComponentsInChildren(); + foreach (var articulationBody in articulationBodies) + { + if (articulationBody.isRoot) + { + articulationBody.Sleep(); + var newWorldPose = articulationBody.transform.position; + newWorldPose.y = transform.localPosition.y + NEW_POSE_MARGIN; + articulationBody.TeleportRoot(newWorldPose, articulationBody.transform.localRotation); + break; + } + } + } yield return waitForEOF; - - } while(lift.IsMoving); + } while (lift.IsMoving); DropLiftedObjects(); @@ -146,21 +159,21 @@ private IEnumerator DoLifting() yield return null; } -// #if UNITY_EDITOR -// // just for test -// void Update() -// { -// if (!lift.IsMoving) -// { -// if (Input.GetKeyUp(KeyCode.U)) -// { -// MoveTo(600); -// } -// else if (Input.GetKeyUp(KeyCode.J)) -// { -// MoveTo(-600); -// } -// } -// } -// #endif + // #if UNITY_EDITOR + // // just for test + // void Update() + // { + // if (!lift.IsMoving) + // { + // if (Input.GetKeyUp(KeyCode.U)) + // { + // MoveTo(600); + // } + // else if (Input.GetKeyUp(KeyCode.J)) + // { + // MoveTo(-600); + // } + // } + // } + // #endif } \ No newline at end of file diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 846f51be..53393414 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -10,7 +10,7 @@ "hash": "0fc6f532e4f47d66d173314efcb906bc7cf0d00f" }, "com.unity.burst": { - "version": "1.7.3", + "version": "1.8.2", "depth": 1, "source": "registry", "dependencies": { @@ -55,7 +55,7 @@ "source": "builtin", "dependencies": { "com.unity.mathematics": "1.2.1", - "com.unity.burst": "1.7.3", + "com.unity.burst": "1.8.2", "com.unity.render-pipelines.core": "12.1.8", "com.unity.shadergraph": "12.1.8" } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index a6626d06..21042f66 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -134,7 +134,7 @@ PlayerSettings: 16:10: 1 16:9: 1 Others: 1 - bundleVersion: 3.0.4 + bundleVersion: 3.0.5 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 @@ -502,6 +502,7 @@ PlayerSettings: switchNetworkInterfaceManagerInitializeEnabled: 1 switchPlayerConnectionEnabled: 1 switchUseNewStyleFilepaths: 0 + switchUseLegacyFmodPriorities: 1 switchUseMicroSleepForYield: 1 switchEnableRamDiskSupport: 0 switchMicroSleepForYieldTime: 25 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 6a95707e..3643b022 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.14f1 -m_EditorVersionWithRevision: 2021.3.14f1 (eee1884e7226) +m_EditorVersion: 2021.3.16f1 +m_EditorVersionWithRevision: 2021.3.16f1 (4016570cf34f)