From 03352fb1432f1390c430c747252f92ad205ffef1 Mon Sep 17 00:00:00 2001 From: DaXcess Date: Sun, 11 Aug 2024 13:51:39 +0200 Subject: [PATCH] Fix spray paint raycasting --- Source/Patches/Items/SprayPaintItemPatches.cs | 10 ++++++++-- Source/Plugin.cs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Patches/Items/SprayPaintItemPatches.cs b/Source/Patches/Items/SprayPaintItemPatches.cs index 10fcad28..5cdf61e8 100644 --- a/Source/Patches/Items/SprayPaintItemPatches.cs +++ b/Source/Patches/Items/SprayPaintItemPatches.cs @@ -11,6 +11,11 @@ namespace LCVR.Patches.Items; [HarmonyPatch] internal static class SprayPaintItemPatches { + /// + /// Offset to make the spray paint come out of the tip of the can instead of from the hand + /// + private static readonly Vector3 SprayOffset = new(-0.1025f, 0.225f, 0.16f); + /// /// Makes the spray paint item spray from your hand instead of your head /// @@ -19,10 +24,11 @@ internal static class SprayPaintItemPatches private static bool SprayPaintFromHand(SprayPaintItem __instance, ref bool __result) { var rayOrigin = VRSession.Instance.LocalPlayer.PrimaryController.InteractOrigin; + var position = rayOrigin.TransformPoint(SprayOffset); - if (__instance.AddSprayPaintLocal(rayOrigin.transform.position, rayOrigin.transform.forward)) + if (__instance.AddSprayPaintLocal(position, rayOrigin.forward)) { - __instance.SprayPaintServerRpc(rayOrigin.transform.position, rayOrigin.transform.forward); + __instance.SprayPaintServerRpc(position, rayOrigin.forward); __result = true; return false; } diff --git a/Source/Plugin.cs b/Source/Plugin.cs index 40929bab..1e34eafd 100644 --- a/Source/Plugin.cs +++ b/Source/Plugin.cs @@ -28,7 +28,7 @@ public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "io.daxcess.lcvr"; public const string PLUGIN_NAME = "LCVR"; - public const string PLUGIN_VERSION = "1.3.0"; + public const string PLUGIN_VERSION = "1.3.1"; private readonly string[] GAME_ASSEMBLY_HASHES = [