void Start() { myEventSystem = GameObject.Find("EventSystem"); laserPointer = GetComponent <SteamVR_LaserPointer>(); laserPointer.PointerIn += LaserPointer_PointerIn; laserPointer.PointerOut += LaserPointer_PointerOut; TeleportArea.SetActive(false); DRTeleportArea.SetActive(false); JapTeleportArea.SetActive(false); ParkingTeleportArea.SetActive(false); BookerOfficeTeleportArea.SetActive(false); layerButtons = LayerMask.NameToLayer("Buttons"); }
void FixedUpdate() { trackedObj = GetComponent <SteamVR_TrackedObject>(); controller = SteamVR_Controller.Input((int)trackedObj.index); if (pointerOnButton) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { btn.onClick.Invoke(); btn = null; pointerOnButton = false; } } if (pointerOnBoxButton) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { boxBtn.onClick.Invoke(); } } if (pointerOnToggle) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { ExecuteEvents.Execute <IPointerClickHandler>(tgl.gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler); tgl = null; } } if (pointerOnFloor && (!pointerOnButton || !pointerOnBoxButton || !pointerOnToggle)) { if (LowPoly.activeInHierarchy) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { LowPolyTeleportArea.SetActive(true); } } if (Bedroom.activeInHierarchy) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { TeleportArea.SetActive(true); } } if (DarkRoom.activeInHierarchy) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { DRTeleportArea.SetActive(true); } } if (JapRoom.activeInHierarchy) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { JapTeleportArea.SetActive(true); } } if (ParkingRoom.activeInHierarchy) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { ParkingTeleportArea.SetActive(true); } } if (BookersOffice.activeInHierarchy) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { BookerOfficeTeleportArea.SetActive(true); } } if (controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad)) { //Invoke Teleport teleportPressed = true; this.GetComponent <SteamVR_Teleporter>().teleportOnClick = true; LowPolyTeleportArea.SetActive(false); TeleportArea.SetActive(false); DRTeleportArea.SetActive(false); JapTeleportArea.SetActive(false); ParkingTeleportArea.SetActive(false); BookerOfficeTeleportArea.SetActive(false); } } if (pointerOnFloor == false) { pointerOnFloor = false; LowPolyTeleportArea.SetActive(false); TeleportArea.SetActive(false); DRTeleportArea.SetActive(false); JapTeleportArea.SetActive(false); BookerOfficeTeleportArea.SetActive(false); } if (canLiftInteractable) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("Picked Up InteractableObject: " + interactableObject); interactableObject.transform.parent = this.gameObject.transform; interactableObject.transform.rotation = this.gameObject.transform.rotation; interactableObject.GetComponent <Rigidbody>().isKinematic = true; interactableObject.GetComponent <Rigidbody>().useGravity = false; //interactableObject.GetComponent<MeshCollider>().isTrigger = true; //this.GetComponent<SphereCollider>().isTrigger = true; } if (controller.GetPressUp(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("Dropped Interactable: " + interactableObject); interactableObject.GetComponent <Rigidbody>().isKinematic = false; interactableObject.GetComponent <Rigidbody>().useGravity = true; //canLiftInteractable = false; DropHoldingObject(); interactableObject.GetComponent <Rigidbody>().velocity = this.GetComponent <Rigidbody>().velocity *Time.deltaTime; if (interactableObject.name == "HarleyProp-Bat") { interactableObject.transform.parent = null; } if (interactableObject.name == "Flashlight") { Debug.Log("Running Flashlight double check"); interactableObject.transform.parent = null; } } } if (this.GetComponent <SteamVR_TrackedController>().triggerPressed&& interactableObject != null) { if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) { Vector3 resetValue = new Vector3(90f, 0f, 0f); interactableObject.transform.position = this.transform.position; interactableObject.transform.localEulerAngles = resetValue; } } }