Add patch for XR Controller state instability, teleporting and turning dont need finger to be lifted

This commit is contained in:
Toomas Tamm 2021-05-28 17:04:43 +03:00
parent ec21a2f53f
commit ef7ed70903
2 changed files with 28 additions and 10 deletions

View File

@ -153,10 +153,9 @@ public class ActionBasedControllerManager : MonoBehaviour
get => m_TeleportModeActivate;
set => m_TeleportModeActivate = value;
}
// State transition actions
[SerializeField]
[Tooltip("The reference to the action of listening to teleport actions.")]
[SerializeField] [Tooltip("The reference to the action of listening to teleport actions.")]
InputActionReference m_NagivationModifier;
/// <summary>
@ -541,11 +540,20 @@ public class ActionBasedControllerManager : MonoBehaviour
var cancelTeleportModeAction = GetInputAction(m_TeleportModeCancel);
var allowNavigationAction = GetInputAction(m_NagivationModifier);
var triggerTeleportMode = teleportModeAction != null && teleportModeAction.IsPressed();
var cancelTeleport = cancelTeleportModeAction != null && cancelTeleportModeAction.IsPressed();
var allowNavigation = allowNavigationAction != null && allowNavigationAction.IsPressed();
if (triggerTeleportMode && !cancelTeleport && allowNavigation)
#region Check if teleport vector is north
Vector2 teleportAxis = teleportModeAction.ReadValue<Vector2>();
bool isNorth = teleportAxis.y > 0.8;
#endregion
if (triggerTeleportMode && !cancelTeleport && allowNavigation && isNorth)
{
TransitionState(m_SelectState, m_TeleportState);
return;
@ -569,13 +577,23 @@ public class ActionBasedControllerManager : MonoBehaviour
var cancelTeleportModeAction = GetInputAction(m_TeleportModeCancel);
var allowNavigationAction = GetInputAction(m_NagivationModifier);
var cancelTeleport = cancelTeleportModeAction != null && cancelTeleportModeAction.triggered;
var releasedTeleport = teleportModeAction != null && teleportModeAction.phase == InputActionPhase.Waiting;
var allowNavigation = allowNavigationAction != null && allowNavigationAction.IsPressed();
if (cancelTeleport || releasedTeleport)
if (cancelTeleport || releasedTeleport || !allowNavigation)
{
if (!cancelTeleport)
{
// Force teleportation
XRRayInteractor interactor = m_TeleportControllerGameObject.GetComponent<XRRayInteractor>();
if (interactor.selectTarget != null)
interactor.interactionManager.ForceSelect(interactor, interactor.selectTarget);
}
TransitionState(m_TeleportState, m_SelectState);
}
}
void OnUpdateInteractState()

View File

@ -496,9 +496,9 @@
},
{
"name": "Teleport Mode Activate",
"type": "Button",
"type": "Value",
"id": "a6c7231d-c55d-4dd4-9e87-877bb5522ef5",
"expectedControlType": "Button",
"expectedControlType": "Vector2",
"processors": "",
"interactions": ""
},