Exemplo n.º 1
0
    void ProcessObject(GameObject go)
    {
        disableLookAts = false;

        Vector3 startPos = characterController.transform.position;

        if (overrideTeleport)
        {
            startPos = new Vector3(-4.276f, 14.500f, -23.279f);
        }

        if (currentMarkerLevel == 2)
        {
            RenderSettings.fog    = true;
            RenderSettings.skybox = skyboxWithGround;
            KingelezCityExteriorRoot.SetActive(true);
        }

        GameObject destinationMarker = MarkerScript.FindClosestMarker(startPos, currentMarkerLevel);

        Debug.Log("markerLevel: " + currentMarkerLevel);

        if (destinationMarker != null)
        {
            Vector3 rayStart = destinationMarker.transform.position;

            if (overrideTeleport)
            {
                writeRotation = true;
                newRotation   = Quaternion.Euler(0.0f, 0.0f, 0.0f);
                rayStart      = startPos;

                overrideTeleport = false;
            }
            Ray        ray = new Ray(rayStart, Vector3.down);
            RaycastHit hit;
            int        layerMask = 1 << 2; //ignore raycast

            bool raycastDown = currentMarkerLevel == 0 ? false : true;

            Vector3 hitPoint = transform.position;

            if (raycastDown && Physics.Raycast(ray, out hit, 100.0f, ~layerMask))
            {
                hitPoint = hit.point;
            }
            else
            {
                hitPoint.y = 0.0f;
            }
            TeleportCharacterController(destinationMarker, hitPoint);
        }
    }