예제 #1
0
    /**
     * FUNCTION NAME: DetectVisibility
     * DESCRIPTION  : Adds and removes objects from the camera's list of objects to track based on visibility in the viewport.
     * INPUTS       : None
     * OUTPUTS      : None
     **/
    void DetectVisibility(LPK_TrackingCamera.TrackingCamera_MoveEvent data)
    {
        //Adding the object to the list of objects to track.
        if (GetComponent <Renderer>() && GetComponent <Renderer>().isVisible&& !m_bHasBeenAdded)
        {
            AddObject();
        }

        //Removing the object from the camera's list of objects to track.
        else if (GetComponent <Renderer>() && !GetComponent <Renderer>().isVisible&& m_bHasBeenAdded)
        {
            RemoveObject();
        }
    }
예제 #2
0
    /**
     * FUNCTION NAME: TrackingCameraMove
     * DESCRIPTION  : Checks the object's location relative to the camera's location for adding and removing objects.
     * INPUTS       : None
     * OUTPUTS      : None
     **/
    void TrackingCameraMoved(LPK_TrackingCamera.TrackingCamera_MoveEvent data)
    {
        Vector2 obj1 = new Vector2(transform.position.x, transform.position.y);
        Vector2 obj2 = new Vector2(data.m_vecCameraLocation.x, data.m_vecCameraLocation.y);

        //Adds the object to the imporant camera.
        if (Vector2.Distance(obj1, obj2) <= m_flMaxAddDistance && !m_bHasBeenAdded)
        {
            AddObject();
        }

        //Removes the object if it was added but is now out of distance.
        else if (Vector2.Distance(obj1, obj2) > m_flMaxAddDistance && m_bHasBeenAdded)
        {
            RemoveObject();
        }
    }