Class RaycastModifier Extends MonoModifier
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
Called for each path that the Seeker calculates after the calculation has finished.
Public Static Methods
Public Variables
Layer mask used for physics raycasting.
Higher quality modes will try harder to find a shorter path.
Offset from the original positions to perform the raycast.
Checks around the line between two points, not just the exact line.
Distance from the ray which will be checked for colliders.
Check for intersections with 2D colliders instead of 3D colliders.
Use raycasting on the graphs.
Use Physics.Raycast to simplify the path.
Public Enums
Inherited Public Members
Private/Protected Members
Handle serialization backwards compatibility.
Handle serialization backwards compatibility.
Check if a straight path between v1 and v2 is valid.