The project needs to detect the arrival of the target point and stop the character animation walking problem
1. First use the following code to detect remainingDistance is 0
if(agent.remainingDistance < agent.stoppingDistance){
Debug.log(“移动结束了”);
}
2. After searching for the post, change it to the following, but the target point is still not detected
if(!agent.pathPending && agent.remainingDistance < agent.stoppingDistance){
Debug.log(“移动结束了”);
}
3. Finally, the following code can be successfully detected
if (!agent.pathPending && agent.remainingDistance < 0.5f)
{
print("移动结束");
animator.SetBool("isMoving", false);
}