示例#1
0
    public bool camera3D1Set    = false;                //Triggers a if statment to store the Traget position


    public void camera1()
    {
        //This is called once on the first time the method is ran
        if (setOrigDefaults)
        {
            originalY = transform.position.y;                                           //Store originalY position
        }

        //Called each time this method is called at the start
        if (!camera3D1Set)
        {
            transform.position = cameraTarget.position;                         //Move camera to the Target Location
            camera3D1Set       = true;                                          //Set to True so this method will not be called each time this method runs
        }


        originalY = movement3D1.getCurrentYAxis();                                                      //Store current Y axis to originalY
        float playerXAxis = movement3D1.getPlayerXMovement();                                           //Get the players X axis

        if (Input.GetAxis("Vertical") == 0 && Input.GetAxis("Horizontal") == 0)                         //Check that the controller is not being moved
        {
            if (transform.position.y > originalY || transform.position.z < originalZ)                   //Check if the camera is currently Not at the original Y and Z location
            {
                zoom3D1In();                                                                            //Call zoom in method
            }
            if (curGround.getCurrentGround() == "slopeGround")                                          //If the player is standing on a slope surface Tag
            //Move the camera's X axis back into place
            {
                transform.position = new Vector3(-playerXAxis - centerPlayerVar, transform.position.y, transform.position.z);
            }
            //Character is being moved - Zoom Out
        }
        else if (transform.position.y < (originalY + maxZoomY) || transform.position.z < (originalZ + maxZoomZ))
        {
            zoom3D1Out();                                                                                                                                       //Max zooms not met so camera can zoom out
        }
        else
        {
            //If the player is moving the camera is also at max zoom out it holds the current X position
            transform.position = new Vector3(-playerXAxis - centerPlayerVar, transform.position.y, transform.position.z);
        }
        //This checks if the Y axis needs to be zoomed out or is at max zoom (1.5f is a Y offset from the players position)
        if (transform.position.y > movement3D1.getCurrentYAxis() + 1.5f)
        {
            //Move the camera up along the Y axis
            transform.position = new Vector3(-playerXAxis - centerPlayerVar, transform.position.y - zoom3D1OutRate, transform.position.z);
        }
        else
        {
            //Camera is at Max Y axis and holds the max Y zoom out position
            transform.position = new Vector3(-playerXAxis - centerPlayerVar, transform.position.y, transform.position.z);
        }
    }