Change Vive wand teleport and turn from touch to press
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Bow
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
{
|
||||
if (!_inAir) return;
|
||||
CheckForCollision();
|
||||
_lastPosition = tip.position;
|
||||
|
||||
@@ -153,6 +153,21 @@ 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.")]
|
||||
InputActionReference m_NagivationModifier;
|
||||
|
||||
/// <summary>
|
||||
/// The reference to the action of activating the teleport mode for this controller."
|
||||
/// </summary>
|
||||
public InputActionReference navigationModifier
|
||||
{
|
||||
get => m_NagivationModifier;
|
||||
set => m_NagivationModifier = value;
|
||||
}
|
||||
|
||||
|
||||
[SerializeField] [Tooltip("The reference to the action of canceling the teleport mode for this controller.")]
|
||||
InputActionReference m_TeleportModeCancel;
|
||||
@@ -448,6 +463,7 @@ public class ActionBasedControllerManager : MonoBehaviour
|
||||
// Enable transitions to Teleport state
|
||||
EnableAction(m_TeleportModeActivate);
|
||||
EnableAction(m_TeleportModeCancel);
|
||||
EnableAction(m_NagivationModifier);
|
||||
|
||||
// Enable turn and move actions
|
||||
EnableAction(m_Turn);
|
||||
@@ -523,11 +539,13 @@ public class ActionBasedControllerManager : MonoBehaviour
|
||||
// Transition from Select state to Teleport state when the user triggers the "Teleport Mode Activate" action but not the "Cancel Teleport" action
|
||||
var teleportModeAction = GetInputAction(m_TeleportModeActivate);
|
||||
var cancelTeleportModeAction = GetInputAction(m_TeleportModeCancel);
|
||||
var allowNavigationAction = GetInputAction(m_NagivationModifier);
|
||||
|
||||
var triggerTeleportMode = teleportModeAction != null && teleportModeAction.triggered;
|
||||
var cancelTeleport = cancelTeleportModeAction != null && cancelTeleportModeAction.triggered;
|
||||
|
||||
if (triggerTeleportMode && !cancelTeleport)
|
||||
var triggerTeleportMode = teleportModeAction != null && teleportModeAction.IsPressed();
|
||||
var cancelTeleport = cancelTeleportModeAction != null && cancelTeleportModeAction.IsPressed();
|
||||
var allowNavigation = allowNavigationAction != null && allowNavigationAction.IsPressed();
|
||||
|
||||
if (triggerTeleportMode && !cancelTeleport && allowNavigation)
|
||||
{
|
||||
TransitionState(m_SelectState, m_TeleportState);
|
||||
return;
|
||||
@@ -549,10 +567,13 @@ public class ActionBasedControllerManager : MonoBehaviour
|
||||
|
||||
var teleportModeAction = GetInputAction(m_TeleportModeActivate);
|
||||
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)
|
||||
TransitionState(m_TeleportState, m_SelectState);
|
||||
}
|
||||
|
||||
37
Assets/Scripts/UnityXR/CustomSnapTurnProvider.cs
Normal file
37
Assets/Scripts/UnityXR/CustomSnapTurnProvider.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Inputs;
|
||||
|
||||
public class CustomSnapTurnProvider : ActionBasedSnapTurnProvider
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("The Input System Action that will be used to read Snap Turn data from the left hand controller. Must be a Value Vector2 Control.")]
|
||||
InputActionProperty m_allowNavigation;
|
||||
/// <summary>
|
||||
/// The Input System Action that will be used to read Snap Turn data sent from the left hand controller. Must be a <see cref="InputActionType.Value"/> <see cref="Vector2Control"/> Control.
|
||||
/// </summary>
|
||||
public InputActionProperty allowNavigation
|
||||
{
|
||||
get => m_allowNavigation;
|
||||
set => SetInputActionProperty(ref m_allowNavigation, value);
|
||||
}
|
||||
|
||||
void SetInputActionProperty(ref InputActionProperty property, InputActionProperty value)
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
property.DisableDirectAction();
|
||||
|
||||
property = value;
|
||||
|
||||
if (Application.isPlaying && isActiveAndEnabled)
|
||||
property.EnableDirectAction();
|
||||
}
|
||||
|
||||
protected override Vector2 ReadInput()
|
||||
{
|
||||
return m_allowNavigation.action.IsPressed() ? base.ReadInput() : Vector2.zero;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UnityXR/CustomSnapTurnProvider.cs.meta
Normal file
11
Assets/Scripts/UnityXR/CustomSnapTurnProvider.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7e3391cd1a2c7e428f26aba850dd78f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user