Using Modifiers

Modifiers are small scripts which can hook into the Seeker and pre- and/or post-process the path before it is returned to the caller.

Modifiers are used by simply attaching the scripts to the same GameObject as the Seeker component is attached to. They will work automatically without any code modifications.

This can, for example, be a Raycast Modifier which removes unnecessary nodes in a path to make it shorter but still valid. Or a Smooth Modifier which subdivides the path and smooths it to make it more aesthetically appealing.

Below is a comparison of a few of the most common types of modifiers/combination of modifiers on a grid graph.

Note

Not all movement scripts use modifiers. The AIPath and AILerp movement scripts support all modifiers; however, the RichAI movement script will ignore most of them (all that smooth and simplify the path). And the FollowerEntity movement script does not use modifiers at all. The RichAI and FollowerEntity scripts include their own path smoothing code. You can still attach other modifiers when using the RichAI movement script.

Simple Smooth Modifier

The simple smooth modifier is a modifier to smooth the path. It can do that either by just subdividing it and moving the vertices closer to each other or by using splines, namely the Bezier curve.
Below are two images showing a path with the smooth modifier turned off first and then on. Note that the smoothed path cuts the corners a bit; this can be a problem with the smooth modifier since it does not take world geometry into account when smoothing. For variable documentation, look at the Simple Smooth Modifier documentation

Funnel Modifier

The funnel modifier is a modifier for simplifying paths on navmeshes or grid graphs in a fast and exact way.
As the name implies, it applies the funnel algorithm to the path.
This will return the shortest path inside the path corridor the pathfinder calculated

You can see a list of all modifiers if you click on Modules above and go to "Modifiers".

Raycast Modifier

The raycast modifier simplifies paths by doing a series of straight line checks. This modifier is primarily useful on grid graphs, though depending on your game, it can be useful if you are using a point graph too.

Custom modifiers

It is also possible to write your own path modifiers.