mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +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.Core.Player;
|
||||||
using ABI_RC.Systems.IK;
|
using ABI_RC.Core.Savior;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
@ -9,36 +9,32 @@ class PlayerSetupPatches
|
||||||
{
|
{
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
[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 = __instance.vrCamera.transform.position;
|
||||||
__state.y = __instance.transform.position.y;
|
__state.y = __instance.transform.position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.SetPlaySpaceScale))]
|
[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;
|
return;
|
||||||
|
|
||||||
Vector3 newPosition = __instance.vrCamera.transform.position;
|
Vector3 newPosition = __instance.vrCamera.transform.position;
|
||||||
newPosition.y = __instance.transform.position.y;
|
newPosition.y = __instance.transform.position.y;
|
||||||
|
|
||||||
Vector3 offset = newPosition - __state;
|
Vector3 offset = newPosition - __state;
|
||||||
|
|
||||||
// Offset _PlayerLocal to keep player in place
|
// Offset _PlayerLocal to keep player in place
|
||||||
__instance.transform.position -= offset;
|
__instance.transform.position -= offset;
|
||||||
|
|
||||||
// TODO: Figure out why VRIK is wonky still
|
// Scale avatar local position to keep avatar in place
|
||||||
// PlayerSetup runs after VRIK solving?? Fuck
|
if (__instance._avatar != null)
|
||||||
/**
|
|
||||||
if (IKSystem.vrik != null)
|
|
||||||
{
|
{
|
||||||
IKSystem.vrik.transform.position += offset;
|
Vector3 scaleDifference = __instance.DivideVectors(__instance._avatar.transform.localScale, __instance.lastScale);
|
||||||
IKSystem.vrik.solver.Reset();
|
__instance._avatar.transform.localPosition = Vector3.Scale(__instance._avatar.transform.localPosition, scaleDifference);
|
||||||
IKSystem.vrik.solver.AddPlatformMotion(offset, Quaternion.identity, __instance.transform.position);
|
|
||||||
}
|
}
|
||||||
**/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ public class PlaySpaceScaleFix : MelonMod
|
||||||
{
|
{
|
||||||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyPatches(Type type)
|
void ApplyPatches(Type type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue