Skip to content

Commit

Permalink
Fix UI controller interactors not rotating with snap turn
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBigz committed Dec 10, 2024
1 parent cc15a10 commit 6e69295
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions TABGVR/Player/VRControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ private void Update()

private void SnapTurn(int direction)
{
UIPorter.UISnapTurnBase?.transform.Rotate(Vector3.up, direction * 45);;
Controllers.SnapTurnParent.transform.Rotate(Vector3.up, direction * 45);
player.m_cameraMovement.transform.Rotate(Vector3.up, direction * 45);
}
Expand Down
14 changes: 12 additions & 2 deletions TABGVR/Util/UIPorter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ internal static class UIPorter
{
private static bool _eventSystemSetUp;

[CanBeNull] internal static GameObject UISnapTurnBase;

internal static GameObject UILeftHand;
internal static GameObject UIRightHand;

Expand Down Expand Up @@ -61,6 +63,12 @@ internal static bool InteractorVisuals

internal static void SetupInteractors(XRNode node)
{
if (!UISnapTurnBase)
{
UISnapTurnBase = new GameObject("TABGVR_UISnapTurnBase");
UISnapTurnBase.transform.SetParent(Controllers.VRFloor.transform, false);
}

if (UILeftHand && node == XRNode.LeftHand) return;
if (UIRightHand && node == XRNode.RightHand) return;

Expand All @@ -79,6 +87,8 @@ internal static void SetupInteractors(XRNode node)
default:
throw new ArgumentOutOfRangeException(nameof(node), node, null);
}

interactionController.transform.SetParent(UISnapTurnBase.transform);

var controller = interactionController.AddComponent<XRController>();
var interactor = interactionController.AddComponent<XRRayInteractor>();
Expand Down Expand Up @@ -121,8 +131,6 @@ internal static void SetupInteractors(XRNode node)
lineRenderer.material = new Material(Shader.Find("Sprites/Default"));

controller.controllerNode = node;

interactionController.transform.SetParent(Controllers.VRFloor.transform, false);
// InteractorMover.Interactors.Add(interactor);
}

Expand All @@ -136,6 +144,8 @@ internal static void SetupEventSystem()

eventSystem.AddComponent<XRUIInputModule>();
eventSystem.GetComponent<StandaloneInputModule>().enabled = false;

UISnapTurnBase = null; // remove UISnapTurnBase if there's already one

_eventSystemSetUp = true;
}
Expand Down

0 comments on commit 6e69295

Please sign in to comment.