public static void VrCamera(bool ena) { GameObject player = GameObject.FindGameObjectWithTag("PlayArea"); if (player == null) { return; } VRTK.VRTK_HeightAdjustTeleport heights = player.GetComponent <VRTK.VRTK_HeightAdjustTeleport>(); VRTK.VRTK_BodyPhysics physicses = player.GetComponent <VRTK.VRTK_BodyPhysics>(); VRTK.VRTK_BasicTeleport basics = player.GetComponent <VRTK.VRTK_BasicTeleport>(); if (heights != null) { heights.enabled = ena; } if (physicses != null) { physicses.enabled = ena; } if (basics != null) { basics.enabled = !ena; } }
public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); theScript = go.GetComponent <VRTK.VRTK_HeightAdjustTeleport>(); if (!everyFrame.Value) { MakeItSo(); Finish(); } }
void Update() { if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { //GameManager.Instance.showTeleportPoints(); } if (Controller.GetPress(SteamVR_Controller.ButtonMask.Touchpad)) { RaycastHit hit; if (Physics.Raycast(trackedObj.transform.position, transform.forward, out hit, 100)) { //if (hit.transform.gameObject.GetComponent<TeleportPoint>() != null) if (hit.collider.gameObject.tag == "Floor") { temp = hit.transform.gameObject; //hit.transform.gameObject.GetComponent<TeleportPoint>().HighlightGreen(); //Debug.Log("test"); teleportDestination = hit.point; // store where it sends you } hitPoint = hit.point; EnablePointer(hit); } } else { pointerObject.SetActive(false); } // 3 if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad)) { GameManager.Instance.infoPanel.AddLine(temp.name + " was it with tag " + temp.tag); if (teleportDestination != Vector3.zero && PTH.CanTeleport) { //GameManager.Instance.infoPanel.AddLine("Teleporting"); VRTK.VRTK_HeightAdjustTeleport TeleScript = CameraRig.GetComponent <VRTK.VRTK_HeightAdjustTeleport>(); Quaternion Rot = Quaternion.identity; RotationZone RotZone = null; foreach (RotationZone rz in GameManager.Instance.RotationZones) { if (rz.InsideZone(teleportDestination)) { //GameManager.Instance.infoPanel.AddLine("RZ " + rz.name); RotZone = rz; break; } } if (RotZone != null) { //GameManager.Instance.infoPanel.AddLine("Got rot point"); if (RotZone.Type == RotationZone.ZoneType.AROUND_POINT) { Vector3 targetDir = RotZone.Orinator.transform.position - teleportDestination; Vector3 newDir = Vector3.RotateTowards(CameraRig.transform.forward, targetDir, 1.0f, 0.0f); newDir.y = 0; Rot = Quaternion.LookRotation(newDir); //GameManager.Instance.infoPanel.AddLine("Around point " + targetDir.ToString() + " " + //newDir.ToString() + " " + Rot.ToString()); //Rot.x = 0; //Rot.z = 0; } else if (RotZone.Type == RotationZone.ZoneType.FORWARD_DIR) { GameManager.Instance.infoPanel.AddLine("Forward Dir"); Rot = RotZone.Orinator.transform.rotation; } } //GameManager.Instance.infoPanel.AddLine("Got here"); TeleScript.Teleport(temp.transform, teleportDestination, Rot, true); PTH.StartCoroutine("TeleportDelay", 1.0f); } //GameManager.Instance.resetTeleportPoint(); teleportDestination = Vector3.zero; } if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { bool IsActive = PlayerMenu.GetActive(); PlayerMenu.SetActive(!IsActive); } }