Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector3 destination;

        if (poi == null)
        {
            destination = Vector3.zero;
        }
        else
        {
            //get the position of the poi
            destination = poi.transform.position;
            //if poi is a projectile, check to see if its at rest
            if (poi.tag == "Projectile")
            {
                //if it is sleeping (that is, not moving)
                if (poi.GetComponent <Rigidbody>().IsSleeping())
                {
                    //return to default view
                    poi = null;
                    if (MissionDemolition.S.shotsLeft == 0)
                    {
                        MissionDemolition.GameOver();
                        MissionDemolition.S.Invoke("StartLevel", 5f);
                    }
                    //in the next update
                    return;
                }
            }
        }
        //limit the x and y to minimum values
        destination.x = Mathf.Max(minXY.x, destination.x);
        destination.y = Mathf.Max(minXY.y, destination.y);
        //interpolate from the current camera position towards destination
        destination = Vector3.Lerp(transform.position, destination, easing);
        //retain a destination.z of camZ
        destination.z = camZ;
        //set the camera to the destination
        transform.position = destination;
        //set the orthographic view of the camera to keep ground in view
        this.GetComponent <Camera>().orthographicSize = destination.y + 10;
    }