//might put this method in a player class to reduce repeated code. private bool canSeePlayer() { float distToPlayer = AIUtility.findWalkableDistance(aiTransform.position, playerTransform.position); bool inFOV = AIUtility.objectInFieldOfView(playerTransform.position, aiTransform, halfFOVRad); bool hasLineOfSight = AIUtility.objectVisibleFromPosition(playerTransform.gameObject, aiTransform.position); return(distToPlayer <= 50f && inFOV && hasLineOfSight); }
//might put this method in a player class to reduce repeated code. private bool canHearPlayer() { bool heard = false; if (heardPlayer && (AIUtility.findWalkableDistance(aiTransform.position, playerTransform.position) <= 20f)) { heard = true; Debug.Log("Heard player"); } heardPlayer = false; return(heard); }
private bool canHearPlayer() { // If we've heard the player and they are fairly nearby, we'll say that we've actually heard the player bool heard = false; if (heardPlayer && (AIUtility.findWalkableDistance(aiTransform.position, playerTransform.position) <= 20f)) { heard = true; Debug.Log("Heard player"); } // Want to clear this so it isn't cheating by always hearing them heardPlayer = false; return(heard); }