Beispiel #1
0
    /// <summary>
    ///Checks if obj is visible to the selfie camera
    /// </summary>
    /// <param name="obj">Object to check visibility of</param>
    public void CheckCameraVisibility(GameObject obj)
    {
        enemyScript     = obj.GetComponent <EnemyScript>();
        isEnemyInCamera = obj.GetComponent <Renderer>().IsVisibleFrom(selfieCamera);

        if (isEnemyInCamera && !enemyScript.MarkedVisible)
        {
            enemyScript.MarkedVisible = true;
            selfieCameraState.AddToVisible(obj);
        }
        else if (!isEnemyInCamera && enemyScript.MarkedVisible)
        {
            enemyScript.MarkedVisible = false;
            selfieCameraState.RemoveFromVisible(obj);
        }
        //else if(obj.GetComponent<Renderer>().IsVisibleFrom(frontCamera))
        //	frontCamera.GetComponent<CameraState>().AddToVisible(obj);
    }