forked from cgvr/DeltaVR
deltavr multiplayer 2.0
This commit is contained in:
45
Assets/ActivateTeleportationRay.cs
Normal file
45
Assets/ActivateTeleportationRay.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
public class ActivateTeleportationRay : MonoBehaviour
|
||||
{
|
||||
public GameObject teleportRay;
|
||||
public float rayHideDelay = 0.1f;
|
||||
|
||||
public InputActionProperty activateTeleportRay;
|
||||
public TeleportationProvider teleportationProvider;
|
||||
|
||||
// Update is called once per frame
|
||||
private void Start()
|
||||
{
|
||||
teleportRay.SetActive(false);
|
||||
activateTeleportRay.action.performed += ShowRay;
|
||||
activateTeleportRay.action.canceled += HideRayPerformed;
|
||||
teleportationProvider.endLocomotion += HideRayPerformed;
|
||||
}
|
||||
|
||||
private void HideRayPerformed(InputAction.CallbackContext obj)
|
||||
{
|
||||
if (!teleportRay.activeSelf) return;
|
||||
if (IsInvoking(nameof(HideRay))) return;
|
||||
Invoke(nameof(HideRay), rayHideDelay);
|
||||
}
|
||||
|
||||
private void HideRayPerformed(LocomotionSystem obj)
|
||||
{
|
||||
if (!teleportRay.activeSelf) return;
|
||||
if (IsInvoking(nameof(HideRay))) return;
|
||||
Invoke(nameof(HideRay), rayHideDelay);
|
||||
}
|
||||
|
||||
private void ShowRay(InputAction.CallbackContext obj)
|
||||
{
|
||||
teleportRay.SetActive(true);
|
||||
}
|
||||
|
||||
private void HideRay()
|
||||
{
|
||||
teleportRay.SetActive(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user