From 18a07f551636577feb0b92b2ba0e92144fbfd18b Mon Sep 17 00:00:00 2001 From: cybensis <cybensis@protonmail.com> Date: Sun, 8 Dec 2024 21:08:01 +1100 Subject: [PATCH] Fixed bug with scopes not working due to collider parent moving --- Patches/Core/Player/WeaponPatches.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Patches/Core/Player/WeaponPatches.cs b/Patches/Core/Player/WeaponPatches.cs index 833e54f..f3ed583 100644 --- a/Patches/Core/Player/WeaponPatches.cs +++ b/Patches/Core/Player/WeaponPatches.cs @@ -722,6 +722,8 @@ private static void SetOpticCamFoV(EFT.CameraControl.OpticComponentUpdater __ins VRGlobals.vrPlayer.scopeUiPosition = __instance.transform_0.FindChild("backLens"); opticSight.gameObject.layer = 6; scopeCollider = opticSight.GetComponent<BoxCollider>(); + if (!scopeCollider) + scopeCollider = opticSight.transform.parent.GetComponent<BoxCollider>(); } if (scopeCollider) { @@ -736,11 +738,16 @@ private static void SetOpticCamFoV(EFT.CameraControl.OpticComponentUpdater __ins VRGlobals.vrOpticController.currentFov = fov; } - if (opticSight.name.Contains("mode_")) - opticSight.transform.parent.GetComponent<BoxCollider>().enabled = true; - else + if (opticSight.name.Contains("mode_")) { + if (opticSight.transform.parent.GetComponent<BoxCollider>()) + opticSight.transform.parent.GetComponent<BoxCollider>().enabled = true; + else if (opticSight.transform.parent.parent.GetComponent<BoxCollider>()) + opticSight.transform.parent.parent.GetComponent<BoxCollider>().enabled = true; + } + else if (opticSight.GetComponent<BoxCollider>()) opticSight.GetComponent<BoxCollider>().enabled = true; - + else if (opticSight.transform.parent.GetComponent<BoxCollider>()) + opticSight.transform.parent.GetComponent<BoxCollider>().enabled = true; }