How can i know the agent is stopped?

  • A* version: [5.3.3]
  • Unity version: [2022.3.36f1]
  • Hi every one
  • Here is my problem
  • There are 2 agents in my scene. AgentA and AgentB, and when i click the ground, both agents will go to the click position. and they are playing moving action animation during the moving. When they arrive at the position, they shoud play idle action, but i dont konw how to check they arrived or not. Sometimes agentA arrive first, sometimes agentB arrive first.
  • I use the agent code in demo file.
  • attchfile
    AStarPathFindComponent.txt (4.4 KB)
    AStarPathFindAgent.txt (7.0 KB)
    is my code

You can use the velocity property on your agent. All built-in movement scripts support this :+1:

From the documentation:

Actual velocity that the agent is moving with.

In world units per second.

This is useful for, for example, selecting which animations to play, and at what speeds.

This value velocity is 0 when the agent starts to move, then slowly increases, then slowly decreases, and finally becomes 0. There is no way to accurately determine whether the agent has stopped by using a value of 0.

Are there any example scenarios and codes about local avoidance of follower entities?

You may want to use something along the lines of velocity.magnitude < .03f. Instead of checking for it being flat at zero, you’ll want to check it against a threshold.

Yes, you’ll want to take a look at the LocalAvoidance2D example. This page has information about adding the example scenes to your project.