I know this is probally simple but how can I add in a max distance of the enemy’s line of sight. So that if I’m within a certain angle and a certain distance the enemy can see me. And two, I have two debug.drawray that draws an angle to represent its angle sight view. So how can I connect both end-points of each line so it become a cone?
Vector3 rayDirection = player.transform.position - transform.position;
// Detect if player is within the field of view
if((Vector3.Angle(rayDirection, transform.forward)) < fieldOfViewRange)
{
if (Physics.Raycast (transform.position, rayDirection, out hit))
{
if (hit.transform.tag == "Player")
{
//GetComponent<NavMeshAgent>().destination = player.position;
renderer.material.color = Color.yellow;
//Debug.Log("Can see player");
isAlterted = true;
}
}