Beispiel #1
0
    void Update()
    {
        switch (camState)
        {
        case CamState.Waiting:
            break;

        case CamState.Playing:
            playerY = player.transform.position.y;
            if (playerY > cameraMaxY)
            {
                transform.position = new Vector3(xCamera, playerY - offset, zCamera);
                cameraMaxY         = transform.position.y + offset;
                cameraMinY         = transform.position.y - offset;
            }
            //if the player is below the min line and they're not at the start position
            if (playerY < cameraMinY && cameraMinY > startPos.y - offset)
            {
                transform.position = new Vector3(xCamera, playerY + offset, zCamera);
                cameraMaxY         = transform.position.y + offset;
                cameraMinY         = transform.position.y - offset;
            }
            break;

        case CamState.Panning:
            if (currentY > introCameraEnd.y)
            {
                transform.position = new Vector3(0, currentY - (cameraSpeed * Time.deltaTime), -10);
                currentY          -= cameraSpeed * Time.deltaTime;
            }
            else
            {
                platformManager.StartCoroutine(platformManager.FlyPlatforms(4.0f));
                camState = CamState.Playing;
            }
            break;
        }

        //update background position according to camera position
        float backgroundY = transform.position.y - (6.0f * ((transform.position.y - introCameraEnd.y) / (introCameraStart.y - introCameraEnd.y) - 0.5f));

        background.transform.position = new Vector3(0, backgroundY, 10);
    }