Class RaycastModifier Extends MonoModifier

Public

Simplifies a path using raycasting.

This modifier will try to remove as many nodes as possible from the path using raycasting (linecasting) to validate the node removal. You can use either graph raycasting or Physics.Raycast. When using graph raycasting, the graph will be traversed and checked for obstacles. When physics raycasting is used, the Unity physics system will be asked if there are any colliders which intersect the line that is currently being checked.

This modifier is primarily intended for grid graphs and layered grid graphs. Though depending on your game it may also be useful for point graphs. However note that point graphs do not have any built-in raycasting so you need to use physics raycasting for that graph.

For navmesh/recast graphs the Pathfinding.FunnelModifier is a much better and faster alternative.

On grid graphs you can combine the FunnelModifier with this modifier by simply attaching both of them to a GameObject with a Seeker. This may or may not give you better results. It will usually follow the border of the graph more closely when they are both used however it more often misses some simplification opportunities. When both modifiers are used then the funnel modifier will run first and simplify the path, and then this modifier will take the output from the funnel modifier and try to simplify that even more.

This modifier has several different quality levels. The highest quality is significantly slower than the lowest quality level (10 times slower is not unusual). So make sure you pick the lowest quality that your game can get away with. You can use the Unity profiler to see if it takes up any significant amount of time. It will show up under the heading "Running Path Modifiers".

Inner Types

Public Methods

Apply (path)

Called for each path that the Seeker calculates after the calculation has finished.

Public

Public Variables

Order
Public
mask

Layer mask used for physics raycasting.

Public
quality

Higher quality modes will try harder to find a shorter path.

Public
raycastOffset

Offset from the original positions to perform the raycast.

Public
thickRaycast

Checks around the line between two points, not just the exact line.

Public
thickRaycastRadius

Distance from the ray which will be checked for colliders.

Public
use2DPhysics

Check for intersections with 2D colliders instead of 3D colliders.

Public
useGraphRaycasting

Use raycasting on the graphs.

Public
useRaycasting

Use Physics.Raycast to simplify the path.

Public

Public Enums

Quality
Public

Inherited Public Members

PreProcess (path)
Public
seeker
Public

Private/Protected Members

ApplyDP (p, points, filter, nnConstraint)
Private
ApplyGreedy (p, points, filter, nnConstraint)
Private
Awake ()
Protected
DPCosts
Private Static
DPParents
Private Static
OnDisable ()
Protected
OnEnable ()

Alerts the Seeker that this modifier exists.

Protected
OnUpgradeSerializedData (version, unityThread)

Handle serialization backwards compatibility.

Protected
Reset ()

Handle serialization backwards compatibility.

Protected
ValidateLine (n1, n2, v1, v2, filter, nnConstraint)

Check if a straight path between v1 and v2 is valid.

Protected
buffer
Private Static
cachedFilter
Private
cachedNNConstraint
Private
iterationsByQuality
Private Static Readonly