Class Funnel
Implements the funnel algorithm as well as various related methods.
http://digestingduck.blogspot.se/2010/03/simple-stupid-funnel-algorithm.html
Usually you do not use this class directly. Instead use the FunnelModifier component.
using UnityEngine;
In the image you can see the output from the code example above. The cyan lines represent off-mesh links.
using Pathfinding;
using Pathfinding.Drawing;
public class FunnelExample : MonoBehaviour {
public Transform target = null;
void Update () {
var path = ABPath.Construct(transform.position, target.position);
AstarPath.StartPath(path);
path.BlockUntilCalculated();
// Apply some default adjustments to the path
// not necessary if you are using the Seeker component
new StartEndModifier().Apply(path);
// Split the path into segments and links
var parts = Funnel.SplitIntoParts(path);
// Optionally simplify the path to make it straighter
var nodes = path.path;
Funnel.Simplify(parts, ref nodes);
using (Draw.WithLineWidth(2)) {
// Go through all the parts and draw them in the scene view
for (int i = 0; i < parts.Count; i++) {
var part = parts[i];
if (part.type == Funnel.PartType.OffMeshLink) {
// Draw off-mesh links as a single line
Draw.Line(part.startPoint, part.endPoint, Color.cyan);
} else {
// Calculate the shortest path through the funnel
var portals = Funnel.ConstructFunnelPortals(nodes, part);
var pathThroghPortals = Funnel.Calculate(portals, splitAtEveryPortal: false);
Draw.Polyline(pathThroghPortals, Color.black);
}
}
}
}
}
Inner Types
Public Static Methods
Splits the path into a sequence of parts which are either off-mesh links or sequences of adjacent triangles.