From 68716a912d3214e6f8a3871497723887ee4f490b Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Fri, 20 Jan 2023 02:56:13 -0600 Subject: [PATCH] fix AMT compatability, fix error spam Avatar Motion Tweaker looks for CheckVR bool instead of MetaPort. Only center & disable VRIK on avatar if it is not actively loading. --- DesktopVRSwitch/DesktopVRSwitchHelper.cs | 33 +++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/DesktopVRSwitch/DesktopVRSwitchHelper.cs b/DesktopVRSwitch/DesktopVRSwitchHelper.cs index 72c873c..5c022ce 100644 --- a/DesktopVRSwitch/DesktopVRSwitchHelper.cs +++ b/DesktopVRSwitch/DesktopVRSwitchHelper.cs @@ -79,12 +79,16 @@ public class DesktopVRSwitchHelper : MonoBehaviour public void LateUpdate() { if (!isAttemptingSwitch) return; - BodySystem.TrackingEnabled = false; - BodySystem.TrackingPositionWeight = 0f; - PlayerSetup.Instance._avatar.transform.position = avatarWorldPos; - PlayerSetup.Instance._avatar.transform.rotation = avatarWorldRot; - MovementSystem.Instance.TeleportToPosRot(avatarWorldPos, avatarWorldRot, false); - MovementSystem.Instance.UpdateColliderCenter(avatarWorldPos); + + if (!PlayerSetup.Instance.avatarIsLoading && PlayerSetup.Instance._avatar != null) + { + BodySystem.TrackingEnabled = false; + BodySystem.TrackingPositionWeight = 0f; + PlayerSetup.Instance._avatar.transform.position = avatarWorldPos; + PlayerSetup.Instance._avatar.transform.rotation = avatarWorldRot; + MovementSystem.Instance.TeleportToPosRot(avatarWorldPos, avatarWorldRot, false); + MovementSystem.Instance.UpdateColliderCenter(avatarWorldPos); + } } internal static IEnumerator AttemptPlatformSwitch(bool forceMode = false) @@ -113,6 +117,7 @@ public class DesktopVRSwitchHelper : MonoBehaviour yield return new WaitForEndOfFrame(); + SetCheckVR(VRMode); SetMetaPort(VRMode); //reset rich presence @@ -256,6 +261,22 @@ public class DesktopVRSwitchHelper : MonoBehaviour throw; } } + + internal static void SetCheckVR(bool isVR) + { + try + { + MelonLogger.Msg($"Set CheckVR hasVrDeviceLoaded to {isVR}."); + CheckVR.Instance.hasVrDeviceLoaded = isVR; + } + catch + { + MelonLogger.Error("Setting CheckVR hasVrDeviceLoaded failed. Is CheckVR.Instance invalid?"); + MelonLogger.Msg("CheckVR.Instance: " + CheckVR.Instance); + throw; + } + } + internal static void SetMetaPort(bool isVR) { try