Example #1
0
    public void TeleportMe(Transform t, bool ignoreTag = false)
    {
        if (_connectedTeleporter == null)
        {
            Debug.Log("Connected teleporter is NULL");
            return;
        }
        if (ignoreTag && teleportableTags.Count == 0)
        {
            Debug.Log("No tags!");
            return;
        }
        if (!running)
        {
            return;
        }
        if (!CheckIfTeleportable(t))
        {
            return;
        }
        if (!_connectedTeleporter.CheckIfTeleportable(t))
        {
            return;
        }
        if (!ignoreTag && !teleportableTags.Contains(t.tag))
        {
            return;
        }

        _connectedTeleporter.running = false;
        _connectedTeleporter.SetVisible_Portal(false);

        Vector3 targetPos = transform.InverseTransformPoint(t.transform.position);

        targetPos            = _connectedTeleporter.transform.TransformPoint(targetPos);
        t.transform.position = targetPos;
        //t.transform.rotation = _connectedTeleporter.exitPosition.rotation;
        t.transform.position += t.transform.forward * .3f;

        Invoke("EnableOtherTeleporter", .25f);
        Invoke("EnableOtherPortalMeshRenderer", .25f);
        Invoke("Flip", .25f);
        print("teleported");
    }