Exemplo n.º 1
0
    private void Teleport(object sender, VRTK.ControllerInteractionEventArgs e)
    {
        Ray        ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 10000f, layerMask))
        {
            teleporter.Teleport(hit.transform, hit.point);
        }
    }
Exemplo n.º 2
0
    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);
        }
    }