Ive been struggling with this for a week now, my agents seem to move fine when I have them wrapped around a conditional if statement like so
void RightClick()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100))
{
agent.SetDestination(hit.point);
}
}
Yet when I try to make them move without it they just refuse to move at all
public void Patrol()
{
//if (patrolPoints.Length == 0)
// return;
//Debug.Log("REEEEEEEEEEEE");
// Set the agent to go to the currently selected destination.
Debug.Log(patrolPoints[currTravelpoint].position); // array of type Transform
agent.SetDestination(patrolPoints[currTravelpoint].position);
// Choose the next point in the array as the destination,
// cycling to the start if necessary.
//currTravelpoint = (currTravelpoint + 1) % patrolPoints.Length;
}
pls, my brain not big enough to understand this, all other docs about this seem to execute it fine without the physics requirement. Enviroment and scene objects cant be at fault since the RightClick() method works without issue.
void RightClick()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
Debug.Log("RIGHT CLICK >>>>> " + Input.mousePosition);
if (Physics.Raycast(ray, out hit, 100))
{
agent.SetDestination(hit.point);
}
}
public void Patrol()
{
//if (patrolPoints.Length == 0)
// return;
//Debug.Log("REEEEEEEEEEEE");
// Set the agent to go to the currently selected destination.
Debug.Log("PATROL METHOD >>>> " + patrolPoints[currTravelpoint].position); // array of type Transform
agent.SetDestination(patrolPoints[currTravelpoint].position);
// Choose the next point in the array as the destination,
// cycling to the start if necessary.
//currTravelpoint = (currTravelpoint + 1) % patrolPoints.Length;
}
Answer for the validity of the points on the navmesh Im sure they are valid, below are the screenshots, one for the right click and one for the patrol (executed when clicking button and left clicking on the navmesh)