How to stop A.I. movement?


I’m trying to find a way to stop my RichAI from moving.
One way I figured this could be done is setting the seeker target to the gameobject itself, but I guess this is hacky since the UpdatePath will still be calculating.

I found a Stop() method in AIFollow but it says that one’s deprecated. I’m using RichAI, how do I properly stop my A.I. from moving?



You can simply set the speed to zero, or disable the component or set the target to the position of the character itself. Either one would work, however setting the target to the same position as the character may make it move forward a small distance until the new path is calculated.

I thought about setting speed to zero but then won’t it keep recalculating paths anyway which would be suboptimal?
And disabling the component any time I want won’t cause any errors? (I presume not since you suggest it but want to make sure :slight_smile: )

No I think that will work fine.

alright, thanks Aaron!

Hey guys,

Any idea when I trigger this code in my units when they were on their way to a target that died, they slowly float away still?

Debug.Log("No enemies in sight. Stopping movement...");
// Figure out how to stop movement here
speed = 0;
GetComponent<RichAI>().maxSpeed = 0;
GetComponent<RichAI>().enabled = false;`

I have an RVO controller on them as well.

Not sure I can help at this point (I started using the plugin recently). I just set the maxSpeed to 0 when the melee enemy gets close enough and starts swinging the weapon and it seems to work fine.


If you set RichAI.enabled = false then that will stop it from telling the RVOController how to move.
The RVOController in the latest release (this has changed in the beta however so this is no longer an issue) takes a velocity as input and it will continue to move in the desired velocity until something tells it not to. When you disable the RichAI component nothing tells the RVOController to stop so it just continues to move.

Thanks Aron. I noticed the beta version is dated form a year ago and seems to not work as well as the newest normal version. Am I downloading the correct thing?


Sorry for the late answer.
Yes, you are downloading the correct thing. There are a few fixes from the latest release that it is missing, but it is mostly ahead of the current release still.

May I ask why there isn’t just a .Stop() or .Pause() method like Unity’s Navmesh system? I’m curious to know for the sake of comprehending the API decisions and proper use of this tool.


Sorry for the late answer:
In the latest beta I have done a major API overhaul of the movement scripts.
The resulting API has both many more features and is easier to use in my opinion. It is also designed to be very similar to Unity’s NavmeshAgent API to make it easy to get started for people used to that API (except in some cases where I have kept previous names for backwards compatibility).

In this API there is a property called isStopped which I think will do exactly what you want. When set to false the agent will immediately start to slow down as quickly as it can, however it will still react to local avoidance.
There is also another property (which has been in the system for a long time) called ‘canMove’. Setting that to false will disable movement calculations completely, which is useful in other scenarios.

Here is the documentation for the isStopped property.

1 Like

Hi Aron,

I’m sorry to revive such an old thread, but I don’t think that this adequately answers the question for anyone looking it up on Google.

I have a follow-up question about isStopped. As the documentation states, setting it to false doesn’t actually clear the path. It stops the characters fine, but, when I inevitably set it back to true, they start moving wherever they were moving before.

How do I reset the path? Setting AI destination to its current position causes movement back on the path which looks terrible – so that is clearly not the way. Setting speed to 0 has the same result as isStopped. I really need them to stop and forget where they were going.




If you want to clear the path you can use

ai.destination = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity);

Setting the destination to an invalid value prevents the AI from immediately recalculating a path to the target. You can alternatively set ai.canSearch = false to achieve this.


Works like a charm! Thank you very much. My previous solution involved a bool that was tracking the fact that I’d stopped the characters – which I was very unhappy with. But this is great!

1 Like

How to stop a FollowerEntity (the proper way)?

Why not just add a method called Stop() to make things simple?


Same issue here, I have the following error when trying to call .SetPath(null) on FollowerEntity.
A .Stop() method would be very nice!

ArgumentException: A component with type:Pathfinding.ECS.ReadyToTraverseOffMeshLink has not been added to the entity. Entities Journaling may be able to help determine more information. Please enable Entities Journaling for a more helpful error message.
Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at ./Library/PackageCache/com.unity.entities@1.2.1/Unity.Entities/EntityComponentStoreDebug.cs:342)
Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.TypeIndex componentTypeIndex) (at ./Library/PackageCache/com.unity.entities@1.2.1/Unity.Entities/EntityComponentStoreDebug.cs:364)
Unity.Entities.EntityDataAccess.SetComponentEnabled (Unity.Entities.Entity entity, Unity.Entities.TypeIndex typeIndex, System.Boolean value) (at ./Library/PackageCache/com.unity.entities@1.2.1/Unity.Entities/EntityDataAccess.cs:1317)
Unity.Entities.EntityManager.SetComponentEnabled[T] (Unity.Entities.Entity entity, System.Boolean value) (at ./Library/PackageCache/com.unity.entities@1.2.1/Unity.Entities/EntityManager.cs:3057)
Pathfinding.FollowerEntity.ClearPath (Unity.Entities.Entity entity) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/AI/FollowerEntity.cs:1465)
Pathfinding.FollowerEntity.SetPath (Unity.Entities.Entity entity, Pathfinding.Path path, System.Boolean updateDestinationFromPath) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/AI/FollowerEntity.cs:1559)
Pathfinding.FollowerEntity.SetPath (Pathfinding.Path path, System.Boolean updateDestinationFromPath) (at ./Library/PackageCache/com.arongranberg.astar@5.1.1/Core/AI/FollowerEntity.cs:1534)

I haven’t used FollowerEntity, but it extends IAstarAI. This provides you with access to methods such as FollowerEntity.canMove, and FollowerEntity.isStopped. I use AIPath.canMove with my custom pathfinding agents when I want to pause movement, and that should provide the same functionality when used with FollowerEntity.