mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[PlaySpaceScaleFix] Scale avatar local position.
This commit is contained in:
parent
e0507cf1a6
commit
829b858e56
2 changed files with 11 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.IK;
|
||||
using ABI_RC.Core.Savior;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -9,36 +9,32 @@ class PlayerSetupPatches
|
|||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
||||
private static void Prefix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
static void Prefix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
{
|
||||
__state = __instance.vrCamera.transform.position;
|
||||
__state.y = __instance.transform.position.y;
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
||||
private static void Postfix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
static void Postfix_PlayerSetup_SetPlaySpaceScale(ref PlayerSetup __instance, ref Vector3 __state)
|
||||
{
|
||||
if (!PlaySpaceScaleFix.EntryEnabled.Value)
|
||||
if (!PlaySpaceScaleFix.EntryEnabled.Value || !MetaPort.Instance.isUsingVr)
|
||||
return;
|
||||
|
||||
Vector3 newPosition = __instance.vrCamera.transform.position;
|
||||
newPosition.y = __instance.transform.position.y;
|
||||
|
||||
|
||||
Vector3 offset = newPosition - __state;
|
||||
|
||||
// Offset _PlayerLocal to keep player in place
|
||||
__instance.transform.position -= offset;
|
||||
|
||||
// TODO: Figure out why VRIK is wonky still
|
||||
// PlayerSetup runs after VRIK solving?? Fuck
|
||||
/**
|
||||
if (IKSystem.vrik != null)
|
||||
// Scale avatar local position to keep avatar in place
|
||||
if (__instance._avatar != null)
|
||||
{
|
||||
IKSystem.vrik.transform.position += offset;
|
||||
IKSystem.vrik.solver.Reset();
|
||||
IKSystem.vrik.solver.AddPlatformMotion(offset, Quaternion.identity, __instance.transform.position);
|
||||
Vector3 scaleDifference = __instance.DivideVectors(__instance._avatar.transform.localScale, __instance.lastScale);
|
||||
__instance._avatar.transform.localPosition = Vector3.Scale(__instance._avatar.transform.localPosition, scaleDifference);
|
||||
}
|
||||
**/
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ public class PlaySpaceScaleFix : MelonMod
|
|||
{
|
||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
}
|
||||
|
||||
|
||||
void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue