I want to check if agent position reach destination. i already checked with Debug.Log, the result is (tagent.position.x==dest1.position.x && tagent.position.z==dest1.position.z) both already has the same value (see pic below, 3rd and 4th log) but “REACHED” wasn’t shown on console, please help
private NavMeshAgent agent;
public Transform dest1, dest2, tagent;
void Start () {
agent = GetComponent<NavMeshAgent> ();
}
void Update () {
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit)) {
if (hit.collider.tag == "group1") {
agent.SetDestination (dest1.position);
Debug.Log ("dest "+dest1.position);
Debug.Log ("tagent"+tagent.position);
if(tagent.position.x==dest1.position.x && tagent.position.z==dest1.position.z)
Debug.Log ("REACHED");
}
}
}
}