Movement scripts
Brief overview of the different movement scripts in the package.
There are several movement scripts included in the package. These are the scripts that actually move some object in your scene along a path, usually a character of some sort. The movement scripts' primary role is to take care of searching for paths and following them.
These scripts are completely optional in this package; you can use pathfinding without using a movement script, or you can write your own movement script. However, for many games they provide a nice base to build your characters on, even if you perhaps later in development replace them with something specifically tailored for your game.
There are four included movement scripts in the package: FollowerEntity, AIPath, RichAI and AILerp. The names of the scripts could, in hindsight, definitely have been chosen better, but I'm hesitant to change them at this point as a large quantity of support material and forum posts refer to these names.
The primary differences between the movement scripts are:
Good all-around movement script which works on grid, navmesh and recast graphs.
Follows paths smoothly and is very responsive.
Uses the Entity Component System behind the scenes.
Works well with local avoidance.
Supports movement in 3D games as well as 2D games.
Works well with off-mesh links.
Knows which node it is traversing at all times.
Not compatible with path modifiers (simplifies the path internally instead).
Stronger guarantees compared to the other movement scripts; it handles edge cases better.
High code complexity.
Cannot be used with Unity's character controller.
A standalone component which does not need a separate Seeker or RVOController component attached to your agent.
Good all-around movement script which works on all graph types.
Follows paths smoothly and responds to physics.
Works well with local avoidance.
Supports movement in 3D games as well as 2D games.
Can traverse off-mesh links, but cannot use special movement logic for them.
Compatible with path modifiers.
Requires the Seeker component, and optionally an RVOController component for local avoidance, attached to your agent.
Uses linear interpolation to move along the path (which is why 'lerp', which stands for linear interpolation, is in the name). Does not use physics in any way.
Follows the path exactly, without any deviations whatsoever.
Due to the above points, it does not make sense to use it with local avoidance, and thus it does not support it.
By far the fastest of the movement scripts, because the movement in itself is much simpler, but keep in mind that if you need any kind of physical realism in the game, you should usually use one of the other movement scripts.
Supports movement in 3D games as well as 2D games.
Compatible with path modifiers.
Low code complexity.
Requires the Seeker component attached to your agent.
Kept for compatibility only. If you are starting a new project, the FollowerEntity script is better in almost every way.
Designed specifically for navmesh/recast graphs and does not work with any other graph types.
Better than the AIPath script at following paths on navmesh-based graphs; it can handle getting pushed off its path better and usually follows the path more smoothly.
Has better support for off-mesh links compared to AIPath.
Works well with local avoidance.
Supports movement in 3D games (movement in the XZ plane), but not 2D.
Works well with off-mesh links.
Not compatible with most path modifiers (simplifies the path internally instead).
Requires the Seeker component, and optionally an RVOController component for local avoidance.
In short, if you are using a navmesh or grid-based graph: try the FollowerEntity component first, otherwise use either AIPath or AILerp depending on what kind of movement style your game needs. Check out the example scenes included in the package to see how the different movement scripts behave.
All movement scripts included in the package implement the Pathfinding.IAstarAI interface. So if you need something that can interact with several different movement scripts, this is a nice interface to use.
For example, these are some properties which you may find useful (these properties exist on all movement scripts):
Position in the world that this agent should move to.
True if the ai has reached the destination.
Actual velocity that the agent is moving with.
Velocity that this agent wants to move with.
If you want your character to follow a specific object, you can attach the AIDestinationSetter component to your agent, and set a Transform as the target. This will, behind the scenes, set the destination property every frame to the position of your chosen target.