Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
1.1 KiB

  1. namespace VRTK.Examples
  2. {
  3. using UnityEngine;
  4. public class ModelVillage_TeleportLocation : VRTK_DestinationMarker
  5. {
  6. public Transform destination;
  7. private bool lastUsePressedState = false;
  8. private void OnTriggerStay(Collider collider)
  9. {
  10. VRTK_ControllerEvents controller = (collider.GetComponent<VRTK_ControllerEvents>() ? collider.GetComponent<VRTK_ControllerEvents>() : collider.GetComponentInParent<VRTK_ControllerEvents>());
  11. if (controller != null)
  12. {
  13. if (lastUsePressedState == true && !controller.triggerPressed)
  14. {
  15. float distance = Vector3.Distance(transform.position, destination.position);
  16. VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(controller.gameObject);
  17. OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerReference));
  18. }
  19. lastUsePressedState = controller.triggerPressed;
  20. }
  21. }
  22. }
  23. }