Skip to content

Commit

Permalink
Item rotation fix and new turning keybind
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Jul 27, 2024
1 parent d622f2e commit 04cdf28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Binary file modified Resources/lethalcompanyvr
Binary file not shown.
4 changes: 3 additions & 1 deletion Source/Input/RemappableControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ public Sprite this[string controlPath]

var path = Regex.Replace(controlPath.ToLowerInvariant(), @"<[^>]+>([^ ]+)", "$1");
var hand = path.Split('/')[0].TrimStart('{').TrimEnd('}');
controlPath = string.Join("/", path.Split('/').Skip(1)).TrimStart('{').TrimEnd('}');
controlPath = Regex.Replace(string.Join("/", path.Split('/').Skip(1)), @"{(.*)}", "$1");

Logger.LogDebug(controlPath);

return (hand, controlPath) switch
{
Expand Down
7 changes: 5 additions & 2 deletions Source/Patches/PlayerControllerPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,11 @@ private static IEnumerable<CodeInstruction> DropItemWithHandRotation(IEnumerable

static int GetHandRotation(PlayerControllerB player)
{
var dir = VRSession.Instance.LocalPlayer.PrimaryController.InteractOrigin.forward;
return (int)(Mathf.Atan2(dir.x, dir.z) * Mathf.Rad2Deg);
var item = player.currentlyHeldObjectServer;
var restOffset = Quaternion.Euler(item.itemProperties.restingRotation.x, 0,
item.itemProperties.restingRotation.z);
return (int)(item.transform.eulerAngles.y - item.itemProperties.floorYOffset - 90 +
restOffset.eulerAngles.y);
}
}
}
Expand Down

0 comments on commit 04cdf28

Please sign in to comment.