From fcb286ae4d3cd563345291b2247a111d6d2941b2 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 13:41:12 -0300 Subject: [PATCH 01/13] Change 3d model when changing weapons. --- DFUVR/Plugin.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index 72fb932..fc085eb 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1018,7 +1018,7 @@ static void Postfix(WeaponManager __instance) public class CorrectWeaponPatch : MonoBehaviour { [HarmonyPrefix] - static void Prefix(WeaponManager __instance) + internal static void Prefix(WeaponManager __instance) { if (Var.weaponObject != null) Destroy(Var.weaponObject); @@ -1074,6 +1074,18 @@ static void Prefix(WeaponManager __instance) } } + [HarmonyPatch(typeof(WeaponManager), "ApplyWeapon")] + public class ApplyWeaponPatch : MonoBehaviour + { + [HarmonyPostfix] + static void Postfix(WeaponManager __instance) + { + if (__instance.ScreenWeapon == null || __instance.ScreenWeapon.SpecificWeapon == null || + __instance.ScreenWeapon.SpecificWeapon.LongName != Var.currentWeaponName) + CorrectWeaponPatch.Prefix(__instance); + } + } + //fixes the billboard orientation of enemies [HarmonyPatch(typeof(DaggerfallMobileUnit), "Update")] public class UnitOrientationPatch : MonoBehaviour From d542f058559f940fbce1cb92ccf82e53b477c590 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 16:45:33 -0300 Subject: [PATCH 02/13] Fix loading weapon state when loading the game. --- DFUVR/Plugin.cs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index fc085eb..54c8717 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1017,25 +1017,32 @@ static void Postfix(WeaponManager __instance) [HarmonyPatch(typeof(WeaponManager), "ToggleSheath")] public class CorrectWeaponPatch : MonoBehaviour { - [HarmonyPrefix] - internal static void Prefix(WeaponManager __instance) + [HarmonyPostfix] + internal static void Postfix(WeaponManager __instance) { if (Var.weaponObject != null) Destroy(Var.weaponObject); - if (__instance.ScreenWeapon == null) + DaggerfallUnityItem rightHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand); + //DaggerfallUnityItem daggerfallUnityItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand); + + if (rightHandItem == null) { Var.currentWeaponName = null; + + Var.sheathObject.GetComponent().enabled = true; + Hands.rHand.SetActive(true); + Hands.lHand.SetActive(true); return; } - Var.currentWeaponName = __instance.ScreenWeapon.SpecificWeapon?.LongName ?? ""; + Var.currentWeaponName = rightHandItem.LongName ?? ""; HandObject currentHandObject = null; - if (__instance.ScreenWeapon.WeaponType != WeaponTypes.Bow && Var.handObjectsByName.ContainsKey(Var.currentWeaponName)) + if (rightHandItem.GetWeaponType() != WeaponTypes.Bow && Var.handObjectsByName.ContainsKey(Var.currentWeaponName)) currentHandObject = Var.handObjectsByName[Var.currentWeaponName]; else - currentHandObject = Var.handObjects[__instance.ScreenWeapon.WeaponType]; + currentHandObject = Var.handObjects[rightHandItem.GetWeaponType()]; GameObject tempObject = currentHandObject.gameObject; @@ -1044,6 +1051,18 @@ internal static void Prefix(WeaponManager __instance) // if it is unsheathing if (__instance.Sheathed) + { + Var.weaponObject.GetComponent().enabled = false; + Var.weaponObject.transform.SetParent(Var.sheathObject.transform); + + Var.weaponObject.transform.localPosition = currentHandObject.sheatedPositionOffset; + Var.weaponObject.transform.localRotation = currentHandObject.sheatedRotationOffset; + Var.sheathObject.GetComponent().enabled = currentHandObject.renderSheated; + + Hands.rHand.SetActive(true); + Hands.lHand.SetActive(true); + } + else { Var.sheathObject.GetComponent().enabled = true; @@ -1080,9 +1099,7 @@ public class ApplyWeaponPatch : MonoBehaviour [HarmonyPostfix] static void Postfix(WeaponManager __instance) { - if (__instance.ScreenWeapon == null || __instance.ScreenWeapon.SpecificWeapon == null || - __instance.ScreenWeapon.SpecificWeapon.LongName != Var.currentWeaponName) - CorrectWeaponPatch.Prefix(__instance); + CorrectWeaponPatch.Postfix(__instance); } } From 417db142d8f6b91d0168d80986d23b1748af9862 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 16:48:38 -0300 Subject: [PATCH 03/13] Remove incorrect message. --- DFUVR/Plugin.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index 54c8717..3e9beea 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1049,7 +1049,6 @@ internal static void Postfix(WeaponManager __instance) Var.weaponObject = Instantiate(tempObject); Var.weaponObject.GetComponent().enabled = true; - // if it is unsheathing if (__instance.Sheathed) { Var.weaponObject.GetComponent().enabled = false; From e58c34612d0567dc0aa3b1392b48f24aac50bb28 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 16:58:52 -0300 Subject: [PATCH 04/13] Fix merge issue. --- DFUVR/Plugin.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index 3e9beea..b538208 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1077,18 +1077,6 @@ internal static void Postfix(WeaponManager __instance) Hands.rHand.SetActive(false); Hands.lHand.SetActive(false); } - else - { - Var.weaponObject.GetComponent().enabled = false; - Var.weaponObject.transform.SetParent(Var.sheathObject.transform); - - Var.weaponObject.transform.localPosition = currentHandObject.sheatedPositionOffset; - Var.weaponObject.transform.localRotation = currentHandObject.sheatedRotationOffset; - Var.sheathObject.GetComponent().enabled = currentHandObject.renderSheated; - - Hands.rHand.SetActive(true); - Hands.lHand.SetActive(true); - } } } From 487dd7837ea1f320eb1bdae6cd3a1c5225810a80 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 17:21:00 -0300 Subject: [PATCH 05/13] Fix multiple hits on enemies. --- DFUVR/Plugin.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index b538208..a496467 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1086,7 +1086,9 @@ public class ApplyWeaponPatch : MonoBehaviour [HarmonyPostfix] static void Postfix(WeaponManager __instance) { - CorrectWeaponPatch.Postfix(__instance); + DaggerfallUnityItem rightHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand); + if (rightHandItem == null || rightHandItem.LongName != Var.currentWeaponName) + CorrectWeaponPatch.Postfix(__instance); } } From 15f84e49fc0dbfa62c1601c488397280298a9082 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 17:24:45 -0300 Subject: [PATCH 06/13] Do not allow the player to hit themselves. Only trigger haptic if the player hit something that caused an action. --- DFUVR/WeaponCollision.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/DFUVR/WeaponCollision.cs b/DFUVR/WeaponCollision.cs index fe1b359..a0ad3b2 100644 --- a/DFUVR/WeaponCollision.cs +++ b/DFUVR/WeaponCollision.cs @@ -6,6 +6,7 @@ using HarmonyLib; using DaggerfallWorkshop.Game.Items; using DaggerfallWorkshop.Game.Questing; + namespace DFUVR { public class WeaponCollision : MonoBehaviour @@ -31,9 +32,8 @@ void Start() private void OnTriggerEnter(Collider other) { - - //Plugin.LoggerInstance.LogInfo("Hit something"); + bool hitSomething = false; if (other.GetComponent()) { @@ -55,41 +55,41 @@ private void OnTriggerEnter(Collider other) hitDirection = hitDirection.normalized; //Debug.Log("Hit Direction: " + hitDirection); - weaponManager.WeaponDamage(currentRightHandWeapon, false, false, hitTransform, hitTransform.localPosition, hitDirection); - + var playerId = GameManager.Instance.PlayerObject.GetInstanceID(); + if (playerId != other.gameObject.GetInstanceID()) + { + weaponManager.WeaponDamage(currentRightHandWeapon, false, false, hitTransform, hitTransform.localPosition, hitDirection); + hitSomething = true; + } } else if (other.GetComponent()) { Plugin.LoggerInstance.LogInfo("Hit action"); - DaggerfallAction action= other.GetComponent(); + DaggerfallAction action = other.GetComponent(); if (Var.weaponManager != null) { GameObject player = (GameObject)AccessTools.Field(typeof(WeaponManager), "player").GetValue(Var.weaponManager); action.Receive(player, DaggerfallAction.TriggerTypes.Attack); + hitSomething = true; } else { Plugin.LoggerInstance.LogError("null"); } - } - else if (other.GetComponent()) + else if (other.GetComponent()) { //Plugin.LoggerInstance.LogInfo("Hit door"); DaggerfallActionDoor actionDoor = other.GetComponent(); if (actionDoor) { actionDoor.AttemptBash(true); + hitSomething = true; } - - } - Haptics.TriggerHapticFeedback(UnityEngine.XR.XRNode.RightHand, 0.6f); - //else if() - + if (hitSomething) + Haptics.TriggerHapticFeedback(UnityEngine.XR.XRNode.RightHand, 0.6f); } - - } } From 8bd99aa148f914fc1de90b5e1c8da97fc5d791f8 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Thu, 22 Jan 2026 19:43:04 -0300 Subject: [PATCH 07/13] Holding weapons in both hands. --- DFUVR/HandObjectLoadList.cs | 6 +- DFUVR/Plugin.cs | 112 ++++++++++++++++++++++++++---------- DFUVR/Sheath.cs | 2 +- DFUVR/Var.cs | 25 +++++++- DFUVR/WeaponCollision.cs | 4 +- 5 files changed, 109 insertions(+), 40 deletions(-) diff --git a/DFUVR/HandObjectLoadList.cs b/DFUVR/HandObjectLoadList.cs index 3e12b6c..a27fd1f 100644 --- a/DFUVR/HandObjectLoadList.cs +++ b/DFUVR/HandObjectLoadList.cs @@ -446,7 +446,6 @@ private HandObjectLoadList(string assetBundlePath, Action postAction new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.LongBlade, WeaponTypes.LongBlade_Magic }, "Sword", Vector3.zero, Quaternion.identity, Vector3.zero, Quaternion.identity, true, true, true), new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Dagger, WeaponTypes.Dagger_Magic }, "Steel_Dagger_512", Vector3.zero, Quaternion.Euler(0, 90, 90), Vector3.zero, Quaternion.Euler(0, 90, 90), true), new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Battleaxe, WeaponTypes.Battleaxe_Magic }, "MM_Axe_01_01_lod2", Vector3.zero, Quaternion.Euler(0, -90, 90), Vector3.zero, Quaternion.Euler(0, 180, 180)), - new HandObjectLoadList("AssetBundles/weapons", null, null, null, new[] { WeaponTypes.None }, "Sheath", Vector3.zero, Quaternion.identity, Vector3.zero, Quaternion.identity, true), new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Mace, WeaponTypes.Mace_Magic }, "mace", new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0), new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0)), new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(MeshCollider), new[] { WeaponTypes.Flail, WeaponTypes.Flail_Magic }, "mace", new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0), new Vector3(0, 0, 0.1f), Quaternion.Euler(90, 0, 0)), new HandObjectLoadList("AssetBundles/weapons", null, typeof(WeaponCollision), typeof(BoxCollider), new[] { WeaponTypes.Warhammer, WeaponTypes.Warhammer_Magic }, "Warhammer_1", Vector3.zero, Quaternion.Euler(0, 0, 90), Vector3.zero, Quaternion.identity), @@ -575,9 +574,10 @@ public static void LoadAllHandObjects(Dictionary handOb } } // this is for accessing by name later - else if (!string.IsNullOrEmpty(handObjectLoad.assetName)) + if (!string.IsNullOrEmpty(handObjectLoad.assetName)) { - handObjectDictionaryByName.Add(handObjectLoad.assetName, new HandObject(handObjectLoad, gameObject)); + if (!handObjectDictionaryByName.ContainsKey(handObjectLoad.assetName)) + handObjectDictionaryByName.Add(handObjectLoad.assetName, new HandObject(handObjectLoad, gameObject)); } handObjectLoad.postAction?.Invoke(gameObject); diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index a496467..3fb3a9c 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -1020,59 +1020,104 @@ public class CorrectWeaponPatch : MonoBehaviour [HarmonyPostfix] internal static void Postfix(WeaponManager __instance) { - if (Var.weaponObject != null) - Destroy(Var.weaponObject); + if (Var.leftWeaponObject != null) + Destroy(Var.leftWeaponObject); + if (Var.rightWeaponObject != null) + Destroy(Var.rightWeaponObject); + DaggerfallUnityItem leftHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand); DaggerfallUnityItem rightHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand); - //DaggerfallUnityItem daggerfallUnityItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand); + + if (leftHandItem == null) + Var.currentLeftWeaponName = "rHandClosed"; + else + Var.currentLeftWeaponName = leftHandItem.LongName; if (rightHandItem == null) + Var.currentRightWeaponName = "rHandClosed"; + else + Var.currentRightWeaponName = rightHandItem.LongName; + + HandObject currentLeftHandObject = null; + if (Var.currentLeftWeaponName != null) { - Var.currentWeaponName = null; + var weaponType = leftHandItem?.GetWeaponType() ?? WeaponTypes.Melee; - Var.sheathObject.GetComponent().enabled = true; - Hands.rHand.SetActive(true); - Hands.lHand.SetActive(true); - return; + if (weaponType != WeaponTypes.Bow && Var.handObjectsByName.ContainsKey(Var.currentLeftWeaponName)) + currentLeftHandObject = Var.handObjectsByName[Var.currentLeftWeaponName]; + else + currentLeftHandObject = Var.handObjects[weaponType]; + + Var.leftWeaponObject = Instantiate(currentLeftHandObject.gameObject); + Var.leftWeaponObject.GetComponent().enabled = true; + + WeaponCollision weaponCollision = Var.leftWeaponObject.GetComponent(); + if (weaponCollision != null && leftHandItem != null) + weaponCollision.item = leftHandItem; } - Var.currentWeaponName = rightHandItem.LongName ?? ""; + HandObject currentRightHandObject = null; + if (Var.currentRightWeaponName != null) + { + var weaponType = rightHandItem?.GetWeaponType() ?? WeaponTypes.Melee; - HandObject currentHandObject = null; - if (rightHandItem.GetWeaponType() != WeaponTypes.Bow && Var.handObjectsByName.ContainsKey(Var.currentWeaponName)) - currentHandObject = Var.handObjectsByName[Var.currentWeaponName]; - else - currentHandObject = Var.handObjects[rightHandItem.GetWeaponType()]; + if (weaponType != WeaponTypes.Bow && Var.handObjectsByName.ContainsKey(Var.currentRightWeaponName)) + currentRightHandObject = Var.handObjectsByName[Var.currentRightWeaponName]; + else + currentRightHandObject = Var.handObjects[weaponType]; - GameObject tempObject = currentHandObject.gameObject; + Var.rightWeaponObject = Instantiate(currentRightHandObject.gameObject); + Var.rightWeaponObject.GetComponent().enabled = true; - Var.weaponObject = Instantiate(tempObject); - Var.weaponObject.GetComponent().enabled = true; + WeaponCollision weaponCollision = Var.rightWeaponObject.GetComponent(); + if (weaponCollision != null && rightHandItem != null) + weaponCollision.item = rightHandItem; + } if (__instance.Sheathed) { - Var.weaponObject.GetComponent().enabled = false; - Var.weaponObject.transform.SetParent(Var.sheathObject.transform); + if (Var.leftWeaponObject != null) + { + Var.leftWeaponObject.GetComponent().enabled = false; + //Var.leftWeaponObject.transform.SetParent(Var.leftSheathObject.transform); + //Var.leftWeaponObject.transform.localPosition = currentLeftHandObject.sheatedPositionOffset; + //Var.leftWeaponObject.transform.localRotation = currentLeftHandObject.sheatedRotationOffset; + } - Var.weaponObject.transform.localPosition = currentHandObject.sheatedPositionOffset; - Var.weaponObject.transform.localRotation = currentHandObject.sheatedRotationOffset; - Var.sheathObject.GetComponent().enabled = currentHandObject.renderSheated; + if (Var.rightWeaponObject != null) + { + Var.rightWeaponObject.GetComponent().enabled = false; + Var.rightWeaponObject.transform.SetParent(Var.rightSheathObject.transform); + Var.rightWeaponObject.transform.localPosition = currentRightHandObject.sheatedPositionOffset; + Var.rightWeaponObject.transform.localRotation = currentRightHandObject.sheatedRotationOffset; + } + + Var.rightSheathObject.GetComponent().enabled = currentRightHandObject.renderSheated; Hands.rHand.SetActive(true); Hands.lHand.SetActive(true); } else { - Var.sheathObject.GetComponent().enabled = true; + Var.rightSheathObject.GetComponent().enabled = true; - if (Var.leftHanded) - Var.weaponObject.transform.SetParent(Var.leftHand.transform); - else - Var.weaponObject.transform.SetParent(Var.rightHand.transform); + if (Var.leftWeaponObject != null) + { + Var.leftWeaponObject.transform.SetParent(Var.offHand.transform); - Var.weaponObject.transform.localPosition = currentHandObject.unsheatedPositionOffset; - Var.weaponObject.transform.localRotation = currentHandObject.unsheatedRotationOffset; - Var.weaponObject.SetActive(true); + Var.leftWeaponObject.transform.localPosition = currentLeftHandObject.unsheatedPositionOffset; + Var.leftWeaponObject.transform.localRotation = currentLeftHandObject.unsheatedRotationOffset; + Var.leftWeaponObject.SetActive(true); + } + + if (Var.rightWeaponObject != null) + { + Var.rightWeaponObject.transform.SetParent(Var.mainHand.transform); + + Var.rightWeaponObject.transform.localPosition = currentRightHandObject.unsheatedPositionOffset; + Var.rightWeaponObject.transform.localRotation = currentRightHandObject.unsheatedRotationOffset; + Var.rightWeaponObject.SetActive(true); + } Hands.rHand.SetActive(false); Hands.lHand.SetActive(false); @@ -1086,8 +1131,13 @@ public class ApplyWeaponPatch : MonoBehaviour [HarmonyPostfix] static void Postfix(WeaponManager __instance) { + DaggerfallUnityItem leftHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand); DaggerfallUnityItem rightHandItem = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand); - if (rightHandItem == null || rightHandItem.LongName != Var.currentWeaponName) + + string leftName = leftHandItem?.LongName ?? "rHandClosed"; + string rightName = rightHandItem?.LongName ?? "rHandClosed"; + + if (leftName != Var.currentLeftWeaponName || rightName != Var.currentRightWeaponName) CorrectWeaponPatch.Postfix(__instance); } } diff --git a/DFUVR/Sheath.cs b/DFUVR/Sheath.cs index 612ecde..0317708 100644 --- a/DFUVR/Sheath.cs +++ b/DFUVR/Sheath.cs @@ -62,7 +62,7 @@ void Start() //sheath.transform.localRotation = Quaternion.identity; assetBundle.Unload(false); - Var.sheathObject=sheath; + Var.rightSheathObject=sheath; //sphere.transform.localPosition = sphere.transform.parent.InverseTransformPoint(Var.sheathOffset); sphere.transform.localPosition = Var.sheathOffset; diff --git a/DFUVR/Var.cs b/DFUVR/Var.cs index 9b4e8c3..53fb7bd 100644 --- a/DFUVR/Var.cs +++ b/DFUVR/Var.cs @@ -80,12 +80,31 @@ public class Var : MonoBehaviour public static GameObject VRParent; public static GameObject debugSphere; + public static GameObject mainHand + { + get + { + return leftHanded ? leftHand : rightHand; + } + } + public static GameObject offHand + { + get + { + return leftHanded ? rightHand : leftHand; + } + } + public static Dictionary handObjects = new Dictionary(); public static Dictionary handObjectsByName = new Dictionary(); - public static GameObject weaponObject; - public static string currentWeaponName; - public static GameObject sheathObject; + public static GameObject rightWeaponObject; + public static GameObject leftWeaponObject; + public static string currentRightWeaponName; + public static string currentLeftWeaponName; + + public static GameObject rightSheathObject; + public static GameObject leftSheathObject; public static int connectedJoysticks; diff --git a/DFUVR/WeaponCollision.cs b/DFUVR/WeaponCollision.cs index a0ad3b2..106c23d 100644 --- a/DFUVR/WeaponCollision.cs +++ b/DFUVR/WeaponCollision.cs @@ -11,6 +11,7 @@ namespace DFUVR { public class WeaponCollision : MonoBehaviour { + public DaggerfallUnityItem item = null; //public float velocityThreshold = 2.0f; //private Rigidbody rb; @@ -51,14 +52,13 @@ private void OnTriggerEnter(Collider other) Vector3 hitDirection = other.transform.position - transform.position; Transform hitTransform = other.transform; WeaponManager weaponManager = GameObject.Find("PlayerAdvanced").GetComponent(); - DaggerfallUnityItem currentRightHandWeapon = (DaggerfallUnityItem)AccessTools.Field(typeof(WeaponManager), "currentRightHandWeapon").GetValue(weaponManager); hitDirection = hitDirection.normalized; //Debug.Log("Hit Direction: " + hitDirection); var playerId = GameManager.Instance.PlayerObject.GetInstanceID(); if (playerId != other.gameObject.GetInstanceID()) { - weaponManager.WeaponDamage(currentRightHandWeapon, false, false, hitTransform, hitTransform.localPosition, hitDirection); + weaponManager.WeaponDamage(item, false, false, hitTransform, hitTransform.localPosition, hitDirection); hitSomething = true; } } From a178fbd006c4f7323d0a2b5046af3224045b9266 Mon Sep 17 00:00:00 2001 From: Stefan Mielke Date: Sun, 25 Jan 2026 12:10:18 -0300 Subject: [PATCH 08/13] Separating hands to allow for 2 sheaths to be shown and used by either hand. Adding lots of null checks. --- DFUVR/DFUVR.csproj | 2 +- DFUVR/HandLabel.cs | 23 +++--- DFUVR/Plugin.cs | 146 +++++++++++++++++++++++++++++++------- DFUVR/Sheath.cs | 109 ---------------------------- DFUVR/SheathCollision.cs | 45 ++++-------- DFUVR/SheathController.cs | 127 +++++++++++++++++++++++++++++++++ DFUVR/SlotCollision.cs | 2 +- DFUVR/SpawnHands.cs | 33 +++++---- DFUVR/Var.cs | 19 ++--- 9 files changed, 308 insertions(+), 198 deletions(-) delete mode 100644 DFUVR/Sheath.cs create mode 100644 DFUVR/SheathController.cs diff --git a/DFUVR/DFUVR.csproj b/DFUVR/DFUVR.csproj index d84be7d..dcea80b 100644 --- a/DFUVR/DFUVR.csproj +++ b/DFUVR/DFUVR.csproj @@ -118,7 +118,7 @@ - + diff --git a/DFUVR/HandLabel.cs b/DFUVR/HandLabel.cs index db56021..3dbe1c5 100644 --- a/DFUVR/HandLabel.cs +++ b/DFUVR/HandLabel.cs @@ -1,19 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; +using UnityEngine; +using UnityEngine.XR; namespace DFUVR { public class HandLabel : MonoBehaviour { - public bool rightHand; + public bool isMainHand; + public XRNode xrHandNode; + public InputDevice inputDevice; + public KeyCode grabButton; + + public void Init(bool isMainHand, XRNode xrHandNode, InputDevice inputDevice, KeyCode grabButton) + { + this.isMainHand = isMainHand; + this.xrHandNode = xrHandNode; + this.inputDevice = inputDevice; + this.grabButton = grabButton; + } + void Start() { Plugin.LoggerInstance.LogInfo("added Handlabel"); } - } } diff --git a/DFUVR/Plugin.cs b/DFUVR/Plugin.cs index 3fb3a9c..247cc5d 100644 --- a/DFUVR/Plugin.cs +++ b/DFUVR/Plugin.cs @@ -562,28 +562,40 @@ static void Prefix(InputManager __instance) //ControllerPatch.flag = false; //float input = Input.GetAxis("Axis5"); //float input = Input.GetAxis(Var.rThumbStickVertical); + + // toggle skybox if (Input.GetKeyDown(Var.acceptButton)) { Var.skyboxToggle = !Var.skyboxToggle; Plugin.LoggerInstance.LogInfo(Var.skyboxToggle); } - var rightHand = InputDevices.GetDeviceAtXRNode(XRNode.RightHand); - Vector2 rThumbStick; - rightHand.TryGetFeatureValue(UnityEngine.XR.CommonUsages.primary2DAxis, out rThumbStick); - + // adjust sheath position + { + //Var.sphereObject.transform.localPosition=Vector3.zero; + if (Var.leftHand != null) + Var.sheathOffset = Var.leftHand.transform.position; - float inputX1 = rThumbStick.x; - float inputY1 = rThumbStick.y; + if (Var.rightSphereSheathObject != null) + Var.rightSphereSheathObject.transform.position = Var.sheathOffset; - float input = rThumbStick.y; + if (Var.leftSphereSheathObject != null) + Var.leftSphereSheathObject.transform.position = new Vector3(-Var.sheathOffset.x, Var.sheathOffset.y, Var.sheathOffset.z); + } + + // adjust height offset + { + var rightHand = InputDevices.GetDeviceAtXRNode(XRNode.RightHand); - Var.heightOffset += input / 100; - //Var.sphereObject.transform.localPosition=Vector3.zero; - Var.sheathOffset = Var.leftHand.transform.position; - Var.sphereObject.transform.position = Var.sheathOffset; - GameObject vrparent = GameObject.Find("VRParent"); - vrparent.transform.localPosition = new Vector3(vrparent.transform.localPosition.x, (float)Var.heightOffset, vrparent.transform.localPosition.z); + Vector2 rThumbStick; + rightHand.TryGetFeatureValue(UnityEngine.XR.CommonUsages.primary2DAxis, out rThumbStick); + + float input = rThumbStick.y; + Var.heightOffset += input / 100; + + GameObject vrparent = GameObject.Find("VRParent"); + vrparent.transform.localPosition = new Vector3(vrparent.transform.localPosition.x, (float)Var.heightOffset, vrparent.transform.localPosition.z); + } } if (Input.GetKeyDown(Var.left2Button)) { @@ -1020,6 +1032,22 @@ public class CorrectWeaponPatch : MonoBehaviour [HarmonyPostfix] internal static void Postfix(WeaponManager __instance) { + if (GameManager.Instance == null) + { + Plugin.LoggerInstance.LogError("GameManager is null"); + return; + } + if (GameManager.Instance.PlayerEntity == null) + { + Plugin.LoggerInstance.LogError("PlayerEntity is null"); + return; + } + if (GameManager.Instance.PlayerEntity.ItemEquipTable == null) + { + Plugin.LoggerInstance.LogError("ItemEquipTable is null"); + return; + } + if (Var.leftWeaponObject != null) Destroy(Var.leftWeaponObject); if (Var.rightWeaponObject != null) @@ -1047,9 +1075,22 @@ internal static void Postfix(WeaponManager __instance) currentLeftHandObject = Var.handObjectsByName[Var.currentLeftWeaponName]; else currentLeftHandObject = Var.handObjects[weaponType]; + if (currentLeftHandObject == null) + { + Plugin.LoggerInstance.LogError("Current left hand object is null"); + return; + } Var.leftWeaponObject = Instantiate(currentLeftHandObject.gameObject); - Var.leftWeaponObject.GetComponent().enabled = true; + if (Var.leftWeaponObject == null) + { + Plugin.LoggerInstance.LogError("Left weapon object is null after instantiation"); + return; + } + + Collider collider = Var.leftWeaponObject.GetComponent(); + if (collider != null) + collider.enabled = true; WeaponCollision weaponCollision = Var.leftWeaponObject.GetComponent(); if (weaponCollision != null && leftHandItem != null) @@ -1065,9 +1106,22 @@ internal static void Postfix(WeaponManager __instance) currentRightHandObject = Var.handObjectsByName[Var.currentRightWeaponName]; else currentRightHandObject = Var.handObjects[weaponType]; + if (currentRightHandObject == null) + { + Plugin.LoggerInstance.LogError("Current right hand object is null"); + return; + } Var.rightWeaponObject = Instantiate(currentRightHandObject.gameObject); - Var.rightWeaponObject.GetComponent().enabled = true; + if (Var.rightWeaponObject == null) + { + Plugin.LoggerInstance.LogError("Right weapon object is null after instantiation"); + return; + } + + Collider collider = Var.rightWeaponObject.GetComponent(); + if (collider != null) + collider.enabled = true; WeaponCollision weaponCollision = Var.rightWeaponObject.GetComponent(); if (weaponCollision != null && rightHandItem != null) @@ -1078,35 +1132,70 @@ internal static void Postfix(WeaponManager __instance) { if (Var.leftWeaponObject != null) { - Var.leftWeaponObject.GetComponent().enabled = false; - //Var.leftWeaponObject.transform.SetParent(Var.leftSheathObject.transform); - //Var.leftWeaponObject.transform.localPosition = currentLeftHandObject.sheatedPositionOffset; - //Var.leftWeaponObject.transform.localRotation = currentLeftHandObject.sheatedRotationOffset; + Collider collider = Var.leftWeaponObject.GetComponent(); + if (collider != null) + collider.enabled = false; + + if (Var.leftSheathObject != null) + Var.leftWeaponObject.transform.SetParent(Var.leftSheathObject.transform); + + Var.leftWeaponObject.transform.localPosition = currentLeftHandObject.sheatedPositionOffset; + Var.leftWeaponObject.transform.localRotation = currentLeftHandObject.sheatedRotationOffset; } if (Var.rightWeaponObject != null) { - Var.rightWeaponObject.GetComponent().enabled = false; - Var.rightWeaponObject.transform.SetParent(Var.rightSheathObject.transform); + Collider collider = Var.rightWeaponObject.GetComponent(); + if (collider != null) + collider.enabled = false; + + if (Var.rightSheathObject != null) + Var.rightWeaponObject.transform.SetParent(Var.rightSheathObject.transform); + Var.rightWeaponObject.transform.localPosition = currentRightHandObject.sheatedPositionOffset; Var.rightWeaponObject.transform.localRotation = currentRightHandObject.sheatedRotationOffset; } - Var.rightSheathObject.GetComponent().enabled = currentRightHandObject.renderSheated; + if (Var.rightSheathObject != null) + { + MeshRenderer meshRenderer = Var.rightSheathObject.GetComponent(); + if (meshRenderer != null) + meshRenderer.enabled = currentRightHandObject.renderSheated; + } + if (Var.leftSheathObject != null) + { + MeshRenderer meshRenderer = Var.leftSheathObject.GetComponent(); + if (meshRenderer != null) + meshRenderer.enabled = currentLeftHandObject.renderSheated; + } Hands.rHand.SetActive(true); Hands.lHand.SetActive(true); } else { - Var.rightSheathObject.GetComponent().enabled = true; + if (Var.rightSheathObject != null) + { + MeshRenderer meshRenderer = Var.rightSheathObject.GetComponent(); + if (meshRenderer != null) + meshRenderer.enabled = true; + } + if (Var.leftSheathObject != null) + { + MeshRenderer meshRenderer = Var.leftSheathObject.GetComponent(); + if (meshRenderer != null) + meshRenderer.enabled = true; + } if (Var.leftWeaponObject != null) { Var.leftWeaponObject.transform.SetParent(Var.offHand.transform); - Var.leftWeaponObject.transform.localPosition = currentLeftHandObject.unsheatedPositionOffset; - Var.leftWeaponObject.transform.localRotation = currentLeftHandObject.unsheatedRotationOffset; + if (currentLeftHandObject != null) + { + Var.leftWeaponObject.transform.localPosition = currentLeftHandObject.unsheatedPositionOffset; + Var.leftWeaponObject.transform.localRotation = currentLeftHandObject.unsheatedRotationOffset; + } Var.leftWeaponObject.SetActive(true); } @@ -1114,8 +1203,11 @@ internal static void Postfix(WeaponManager __instance) { Var.rightWeaponObject.transform.SetParent(Var.mainHand.transform); - Var.rightWeaponObject.transform.localPosition = currentRightHandObject.unsheatedPositionOffset; - Var.rightWeaponObject.transform.localRotation = currentRightHandObject.unsheatedRotationOffset; + if (currentRightHandObject != null) + { + Var.rightWeaponObject.transform.localPosition = currentRightHandObject.unsheatedPositionOffset; + Var.rightWeaponObject.transform.localRotation = currentRightHandObject.unsheatedRotationOffset; + } Var.rightWeaponObject.SetActive(true); } diff --git a/DFUVR/Sheath.cs b/DFUVR/Sheath.cs deleted file mode 100644 index 0317708..0000000 --- a/DFUVR/Sheath.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using BepInEx; -using DaggerfallWorkshop.Game; -using UnityEngine.XR; - - -namespace DFUVR -{ - public class SheathController : MonoBehaviour - { - public static GameObject sheath; - public static GameObject sphere; - public static SphereCollider sphereCollider; - public static GameObject sheathOB; - private static bool gripFlag=false; - private static bool alreadyGripped=false; - void Start() - { - sphere = new GameObject("Sphere"); - sphere.transform.parent=GameObject.Find("Body").transform; - if (GameObject.Find("Body") == null) { Plugin.LoggerInstance.LogError("Body not found. Are you a ghost? Or did I just fuck smthn up?"); } - //sphere.transform.localPosition = new Vector3(-0.155f,0,0); - //sphere.transform.localPosition = Var.sheathOffset; - //sphere.transform.localPosition = sphere.transform.parent.InverseTransformPoint(Var.sheathOffset); - sphere.transform.Rotate(-231.724f, 0, 0); - - - sphere.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f); - - sphereCollider = sphere.AddComponent(); - sphereCollider.radius = 0.25f; - sphereCollider.isTrigger = true; - Var.sphereObject = sphere; - sphere.AddComponent(); - - Rigidbody rb=sphere.AddComponent(); - rb.isKinematic = true; - rb.useGravity=false; - //DebugSphere.CreateVisualizer(sphereCollider); - - string assetBundlePath = Path.Combine(Paths.PluginPath, "AssetBundles/weapons"); - - - AssetBundle assetBundle = AssetBundle.LoadFromFile(assetBundlePath); - - GameObject sheathInstance = assetBundle.LoadAsset("Sheath"); - - GameObject sheath = Instantiate(sheathInstance); - - sheath.transform.parent = sphere.transform; - sheath.transform.localRotation = Quaternion.identity; - - sheathOB = sheath; - //GameObject sheath = new GameObject("Sheath"); - //sheath.transform.parent = sphere.transform; - //sheath.transform.localRotation = Quaternion.identity; - - assetBundle.Unload(false); - Var.rightSheathObject=sheath; - - //sphere.transform.localPosition = sphere.transform.parent.InverseTransformPoint(Var.sheathOffset); - sphere.transform.localPosition = Var.sheathOffset; - - } - //this will handle all interaction with the Sheath - - void Update() - { - if (Var.isNotOculus) - { - bool gripButton; - var rightHand = InputDevices.GetDeviceAtXRNode(XRNode.RightHand); - if (Var.leftHanded) { rightHand = InputDevices.GetDeviceAtXRNode(XRNode.RightHand); } - rightHand.TryGetFeatureValue(CommonUsages.gripButton, out gripButton); - //rightHand.TryGetFeatureValue(CommonUsages.secondaryButton, out secondaryButton); - - if (gripButton) { gripFlag = true; } - if(!gripButton) { gripFlag= false; alreadyGripped = false; } - if ((gripFlag && SheathCollision.flag) && !alreadyGripped) - { - alreadyGripped = true; - GameObject.Find("PlayerAdvanced").GetComponent().ToggleSheath(); - } - } - if (Input.GetKeyDown(Var.gripButton)) - { - gripFlag = true; - } - if(Input.GetKeyUp(Var.gripButton)) { gripFlag = false; alreadyGripped = false; } - if ((gripFlag && SheathCollision.flag)&&!alreadyGripped) - { - alreadyGripped = true; - GameObject.Find("PlayerAdvanced").GetComponent().ToggleSheath(); - - - } - - - } - - - } -} diff --git a/DFUVR/SheathCollision.cs b/DFUVR/SheathCollision.cs index 85fd9f8..f240c46 100644 --- a/DFUVR/SheathCollision.cs +++ b/DFUVR/SheathCollision.cs @@ -1,47 +1,30 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using DaggerfallWorkshop; +using UnityEngine; + namespace DFUVR { - public class SheathCollision:MonoBehaviour + public class SheathCollision : MonoBehaviour { - public static bool flag=false; - public static bool rightHand=true; + public HandLabel handInside = null; + void OnTriggerEnter(Collider other) { - if (other.gameObject.GetComponent() != null) - { - - if (other.gameObject.GetComponent().rightHand == false) - { - Haptics.TriggerHapticFeedback(UnityEngine.XR.XRNode.LeftHand, 0.6f); - } - else - { - Haptics.TriggerHapticFeedback(UnityEngine.XR.XRNode.RightHand, 0.6f); - flag = true; - - } - - //Plugin.LoggerInstance.LogInfo("Entered Collider"); - - } + var handLabel = other.gameObject.GetComponent(); + if (handLabel == null) + return; + Haptics.TriggerHapticFeedback(handLabel.xrHandNode, 0.6f); + handInside = handLabel; + //Plugin.LoggerInstance.LogInfo("Entered Collider"); } - void OnTriggerExit(Collider other) + + void OnTriggerExit(Collider other) { if (other.gameObject.GetComponent() != null) { - flag = false; + handInside = null; //Plugin.LoggerInstance.LogInfo("Exited Collider"); - } - } } } diff --git a/DFUVR/SheathController.cs b/DFUVR/SheathController.cs new file mode 100644 index 0000000..b8088c5 --- /dev/null +++ b/DFUVR/SheathController.cs @@ -0,0 +1,127 @@ +using System.IO; +using UnityEngine; +using BepInEx; +using DaggerfallWorkshop.Game; +using UnityEngine.XR; +using System; + +namespace DFUVR +{ + public class SheathController : MonoBehaviour + { + public GameObject sheath; + public GameObject sphere; + public SphereCollider sphereCollider; + public GameObject sheathOB; + public SheathCollision sheathCollision; + + public bool isLeftSheath = false; + + private bool isGripPressed = false; + private bool alreadyGripped = false; + + void Start() + { + sphere = new GameObject("Sphere" + Guid.NewGuid()); + + var body = GameObject.Find("Body"); + if (body == null) + Plugin.LoggerInstance.LogError("Body not found. Are you a ghost? Or did I just fuck smthn up?"); + else + sphere.transform.parent = body.transform; + + //sphere.transform.localPosition = new Vector3(-0.155f,0,0); + //sphere.transform.localPosition = Var.sheathOffset; + //sphere.transform.localPosition = sphere.transform.parent.InverseTransformPoint(Var.sheathOffset); + //sphere.transform.Rotate(-231.724f, 0, 0); + sphere.transform.Rotate(-300f, 0, 0); + sphere.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f); + + sphereCollider = sphere.AddComponent(); + sphereCollider.radius = 0.25f; + sphereCollider.isTrigger = true; + + sheathCollision = sphere.AddComponent(); + + Rigidbody rb = sphere.AddComponent(); + rb.isKinematic = true; + rb.useGravity = false; + //DebugSphere.CreateVisualizer(sphereCollider); + + string assetBundlePath = Path.Combine(Paths.PluginPath, "AssetBundles/weapons"); + AssetBundle assetBundle = AssetBundle.LoadFromFile(assetBundlePath); + GameObject sheathAsset = assetBundle.LoadAsset("Sheath"); + assetBundle.Unload(false); + + GameObject sheath = Instantiate(sheathAsset); + sheath.transform.parent = sphere.transform; + sheath.transform.localRotation = Quaternion.identity; + + sheathOB = sheath; + //GameObject sheath = new GameObject("Sheath"); + //sheath.transform.parent = sphere.transform; + //sheath.transform.localRotation = Quaternion.identity; + + //sphere.transform.localPosition = sphere.transform.parent.InverseTransformPoint(Var.sheathOffset); + sphere.transform.localPosition = Var.sheathOffset; + + if (isLeftSheath) + { + Var.leftSphereSheathObject = sphere; + Var.leftSheathObject = sheathOB; + MirrorSheathPosition(); + } + else + { + Var.rightSphereSheathObject = sphere; + Var.rightSheathObject = sheathOB; + } + } + + //this will handle all interaction with the Sheath + void Update() + { + var hand = sheathCollision.handInside; + if (hand == null) + return; + + if (Var.isNotOculus) + { + hand.inputDevice.TryGetFeatureValue(CommonUsages.gripButton, out bool gripButton); + if (gripButton) + { + isGripPressed = true; + } + else + { + isGripPressed = false; + alreadyGripped = false; + } + } + else + { + if (Input.GetKeyDown(hand.grabButton)) + isGripPressed = true; + + if (Input.GetKeyUp(hand.grabButton)) + { + isGripPressed = false; + alreadyGripped = false; + } + } + + if (isGripPressed && !alreadyGripped) + { + alreadyGripped = true; + GameObject.Find("PlayerAdvanced").GetComponent().ToggleSheath(); + } + } + + private void MirrorSheathPosition() + { + Vector3 localPos = sphere.transform.localPosition; + localPos.x = -localPos.x; + sphere.transform.localPosition = localPos; + } + } +} diff --git a/DFUVR/SlotCollision.cs b/DFUVR/SlotCollision.cs index 6c4d0f6..77a28a6 100644 --- a/DFUVR/SlotCollision.cs +++ b/DFUVR/SlotCollision.cs @@ -17,7 +17,7 @@ void OnTriggerEnter(Collider other) { //Plugin.LoggerInstance.LogInfo("Collision detected"); - if (other.gameObject.GetComponent().rightHand == false) + if (other.gameObject.GetComponent().isMainHand == false) { Haptics.TriggerHapticFeedback(UnityEngine.XR.XRNode.LeftHand, 0.6f); } diff --git a/DFUVR/SpawnHands.cs b/DFUVR/SpawnHands.cs index f7935d2..5d9acfc 100644 --- a/DFUVR/SpawnHands.cs +++ b/DFUVR/SpawnHands.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using UnityEngine; using UnityEngine.SpatialTracking; +using UnityEngine.XR; using static DaggerfallWorkshop.Game.InputManager;//for slots namespace DFUVR @@ -25,27 +26,31 @@ public static void Spawn() Var.leftHand.transform.parent = GameObject.Find("VRParent").transform; - TrackedPoseDriver rightTracker=Var.rightHand.AddComponent(); + TrackedPoseDriver rightTracker = Var.rightHand.AddComponent(); TrackedPoseDriver leftTracker = Var.leftHand.AddComponent(); rightTracker.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRController, TrackedPoseDriver.TrackedPose.RightPose); leftTracker.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRController, TrackedPoseDriver.TrackedPose.LeftPose); - SphereCollider rCollider=Var.rightHand.AddComponent(); + SphereCollider rCollider = Var.rightHand.AddComponent(); SphereCollider lCollider = Var.leftHand.AddComponent(); rCollider.radius = 0.0668935f; lCollider.radius = 0.0668935f; rCollider.isTrigger = true; - lCollider.isTrigger=true; - Var.rightHand.AddComponent().rightHand=true; - Var.leftHand.AddComponent().rightHand = false; + lCollider.isTrigger = true; - if (Var.leftHanded) { - Var.rightHand.GetComponent().rightHand = false; - Var.leftHand.GetComponent().rightHand = true; + if (Var.leftHanded) + { + Var.rightHand.AddComponent().Init(false, XRNode.RightHand, InputDevices.GetDeviceAtXRNode(XRNode.RightHand), Var.gripButton); + Var.leftHand.AddComponent().Init(true, XRNode.LeftHand, InputDevices.GetDeviceAtXRNode(XRNode.LeftHand), Var.lGripButton); + } + else + { + Var.rightHand.AddComponent().Init(true, XRNode.RightHand, InputDevices.GetDeviceAtXRNode(XRNode.RightHand), Var.gripButton); + Var.leftHand.AddComponent().Init(false, XRNode.LeftHand, InputDevices.GetDeviceAtXRNode(XRNode.LeftHand), Var.lGripButton); } - + //Rigidbody rHandBody=Var.rightHand.AddComponent(); //Rigidbody lHandBody = Var.leftHand.AddComponent(); @@ -59,8 +64,8 @@ public static void Spawn() AssetBundle assetBundle = AssetBundle.LoadFromFile(assetBundlePath); - GameObject controllerPrefab = assetBundle.LoadAsset("vr_controller_01_mrhat"); + assetBundle.Unload(false); rHand = Instantiate(controllerPrefab); lHand= Instantiate(controllerPrefab); @@ -83,8 +88,12 @@ public static void Spawn() Var.body = new GameObject("Body"); Var.body.AddComponent(); - Var.body.AddComponent(); - assetBundle.Unload(false); + SheathController rightSheath = Var.body.AddComponent(); + rightSheath.isLeftSheath = false; + + SheathController leftSheath = Var.body.AddComponent(); + leftSheath.isLeftSheath = true; + try { string watchBundlePath = Path.Combine(pluginFolderPath, "AssetBundles/watchandfonts"); diff --git a/DFUVR/Var.cs b/DFUVR/Var.cs index 53fb7bd..6414d68 100644 --- a/DFUVR/Var.cs +++ b/DFUVR/Var.cs @@ -43,9 +43,10 @@ public class Var : MonoBehaviour public static Vector3 sheathOffset; public static bool leftHanded; - - public static GameObject sphereObject; + + public static GameObject rightSphereSheathObject; + public static GameObject leftSphereSheathObject; //Default Bindings public static KeyCode gripButton = KeyCode.JoystickButton5; //public static KeyCode gripButton = KeyCode.JoystickButton5; @@ -167,8 +168,8 @@ public static void InitKeyboard() Button[]buttons=keyboard.GetComponentsInChildren