[Open online documentation to see videos] | \xmlonly |
[Open online documentation to see videos] | \xmlonly |
[Open online documentation to see videos] | \xmlonly |
[Open online documentation to see videos] | \xmlonly |
[Open online documentation to see videos] | \xmlonly |
+ /// IEnumerator Start () {
+ /// ai.destination = somePoint;
+ /// // Start to search for a path to the destination immediately
+ /// ai.SearchPath();
+ /// // Wait until the agent has reached the destination
+ /// while (!ai.reachedDestination) {
+ /// yield return null;
+ /// }
+ /// // The agent has reached the destination now
+ /// }
+ ///
+ ///
+ /// See:
+ /// IEnumerator Start () {
+ /// ai.destination = somePoint;
+ /// // Start to search for a path to the destination immediately
+ /// ai.SearchPath();
+ /// // Wait until the agent has reached the destination
+ /// while (!ai.reachedDestination) {
+ /// yield return null;
+ /// }
+ /// // The agent has reached the destination now
+ /// }
+ ///
+ ///
+ /// IEnumerator Start () {
+ /// ai.destination = somePoint;
+ /// // Start to search for a path to the destination immediately
+ /// // Note that the result may not become available until after a few frames
+ /// // ai.pathPending will be true while the path is being calculated
+ /// ai.SearchPath();
+ /// // Wait until we know for sure that the agent has calculated a path to the destination we set above
+ /// while (ai.pathPending || !ai.reachedEndOfPath) {
+ /// yield return null;
+ /// }
+ /// // The agent has reached the destination now
+ /// }
+ ///
+ ///
+ /// var buffer = new List();
+ /// ai.GetRemainingPath(buffer, out bool stale);
+ /// for (int i = 0; i < buffer.Count - 1; i++) {
+ /// Debug.DrawLine(buffer[i], buffer[i+1], Color.red);
+ /// }
+ ///
+ /// [Open online documentation to see images]
+ ///
+ /// // Disable the automatic path recalculation
+ /// ai.canSearch = false;
+ /// var pointToAvoid = enemy.position;
+ /// // Make the AI flee from the enemy.
+ /// // The path will be about 20 world units long (the default cost of moving 1 world unit is 1000).
+ /// var path = FleePath.Construct(ai.position, pointToAvoid, 1000 * 20);
+ /// ai.SetPath(path);
+ ///
+ /// // If you want to make use of properties like ai.reachedDestination or ai.remainingDistance or similar
+ /// // you should also set the destination property to something reasonable.
+ /// // Since the agent's own path recalculation is disabled, setting this will not affect how the paths are calculated.
+ /// // ai.destination = ...
+ ///
+ ///
+ /// ai.Move(someVector);
+ /// ai.FinalizeMovement(ai.position, ai.rotation);
+ ///
+ ///
+ /// void Update () {
+ /// // Disable the AIs own movement code
+ /// ai.canMove = false;
+ /// Vector3 nextPosition;
+ /// Quaternion nextRotation;
+ /// // Calculate how the AI wants to move
+ /// ai.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
+ /// // Modify nextPosition and nextRotation in any way you wish
+ /// // Actually move the AI
+ /// ai.FinalizeMovement(nextPosition, nextRotation);
+ /// }
+ ///
+ /// seeker.graphMask = 1 << 3;
+ ///
+ /// See: bitmasks (view in online documentation for working links)
+ ///
+ /// Note that this field only stores which graph indices that are allowed. This means that if the graphs change their ordering
+ /// then this mask may no longer be correct.
+ ///
+ /// If you know the name of the graph you can use the
+ /// GraphMask mask1 = GraphMask.FromGraphName("My Grid Graph");
+ /// GraphMask mask2 = GraphMask.FromGraphName("My Other Grid Graph");
+ ///
+ /// NNConstraint nn = NNConstraint.Default;
+ ///
+ /// nn.graphMask = mask1 | mask2;
+ ///
+ /// // Find the node closest to somePoint which is either in 'My Grid Graph' OR in 'My Other Grid Graph'
+ /// var info = AstarPath.active.GetNearest(somePoint, nn);
+ ///
+ ///
+ /// Some overloads of the
+ /// var seeker = GetComponent();
+ /// Path p = seeker.GetNewPath (transform.position, transform.position+transform.forward*100);
+ /// // Disable heuristics on just this path for example
+ /// p.heuristic = Heuristic.None;
+ /// seeker.StartPath (p, OnPathComplete);
+ ///
+ /// Deprecated: Use ABPath.Construct(start, end, null) instead.
+ ///
+ /// AstarPath.active.data.GetNodes(node => {
+ /// Debug.Log("I found a node at position " + (Vector3)node.position);
+ /// });
+ ///
+ ///
+ /// See:
+ /// foreach (GridGraph graph in AstarPath.data.FindGraphsOfType (typeof(GridGraph))) {
+ /// //Do something with the graph
+ /// }
+ ///
+ /// See: AstarPath.RegisterSafeNodeUpdate
+ /// foreach (IUpdatableGraph graph in AstarPath.data.GetUpdateableGraphs ()) {
+ /// //Do something with the graph
+ /// }
+ /// See: AstarPath.AddWorkItem
+ /// See: Pathfinding.IUpdatableGraph
+ /// foreach (IRaycastableGraph graph in AstarPath.data.GetRaycastableGraphs ()) {
+ /// //Do something with the graph
+ /// }
+ /// See: Pathfinding.IRaycastableGraph
+ /// Deprecated: Deprecated because it is not used by the package internally and the use cases are few. Iterate through the intersectionPoint = start1 + factor1 * (end1-start1)
+ /// intersectionPoint2 = start2 + factor2 * (end2-start2)
+ /// Lines are treated as infinite.\n
+ /// false is returned if the lines are parallel and true if they are not.
+ /// Only the XZ coordinates are used.
+ /// intersectionPoint = start1 + factor1 * (end1-start1)
+ /// intersectionPoint2 = start2 + factor2 * (end2-start2)
+ /// Lines are treated as infinite.\n
+ /// false is returned if the lines are parallel and true if they are not.
+ /// Only the XZ coordinates are used.
+ /// intersectionPoint = start1 + factor * (end1-start1)
+ /// Lines are treated as infinite.\n
+ ///
+ /// The second "line" is treated as a ray, meaning only matches on start2 or forwards towards end2 (and beyond) will be returned
+ /// If the point lies on the wrong side of the ray start, Nan will be returned.
+ ///
+ /// NaN is returned if the lines are parallel.
+ /// intersectionPoint = start1 + intersectionFactor * (end1-start1)
.
+ /// Lines are treated as infinite.\n
+ /// -1 is returned if the lines are parallel (note that this is a valid return value if they are not parallel too)
+ ///
+ /// // Create a new AstarPath object on Start and apply some default settings
+ /// public void Start () {
+ /// AstarPath.OnAwakeSettings += ApplySettings;
+ /// AstarPath astar = gameObject.AddComponent();
+ /// }
+ ///
+ /// public void ApplySettings () {
+ /// // Unregister from the delegate
+ /// AstarPath.OnAwakeSettings -= ApplySettings;
+ /// // For example threadCount should not be changed after the Awake call
+ /// // so here's the only place to set it if you create the component during runtime
+ /// AstarPath.active.threadCount = ThreadCount.One;
+ /// }
+ ///
+ ///
+ /// AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
+ /// // Safe to update graphs here
+ /// var node = AstarPath.active.GetNearest(transform.position).node;
+ /// node.Walkable = false;
+ /// }));
+ ///
+ ///
+ /// See:
+ /// AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
+ /// // Safe to update graphs here
+ /// var node = AstarPath.active.GetNearest(transform.position).node;
+ /// node.Walkable = false;
+ /// }));
+ ///
+ ///
+ /// See:
+ /// AddWorkItem(new AstarWorkItem(callback));
+ ///
+ ///
+ /// See:
+ /// AddWorkItem(new AstarWorkItem(callback));
+ ///
+ ///
+ /// See:
+ /// AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
+ /// // Safe to update graphs here
+ /// var node = AstarPath.active.GetNearest(transform.position).node;
+ /// node.Walkable = false;
+ /// }));
+ ///
+ ///
+ ///
+ /// AstarPath.active.AddWorkItem(() => {
+ /// // Safe to update graphs here
+ /// var node = AstarPath.active.GetNearest(transform.position).node;
+ /// node.position = (Int3)transform.position;
+ /// });
+ ///
+ ///
+ /// See:
+ /// UpdateGraphs(new GraphUpdateObject(bounds));
+ ///
+ ///
+ /// See: FlushGraphUpdates
+ /// See: batchGraphUpdates
+ /// See: graph-updates (view in online documentation for working links)
+ ///
+ /// var graphLock = AstarPath.active.PausePathfinding();
+ /// // Here we can modify the graphs safely. For example by adding a new node to a point graph
+ /// var node = AstarPath.active.data.pointGraph.AddNode((Int3) new Vector3(3, 1, 4));
+ ///
+ /// // Allow pathfinding to resume
+ /// graphLock.Release();
+ ///
+ ///
+ /// Returns: A lock object. You need to call
+ /// // Recalculate all graphs
+ /// AstarPath.active.Scan();
+ ///
+ /// // Recalculate only the first grid graph
+ /// var graphToScan = AstarPath.active.data.gridGraph;
+ /// AstarPath.active.Scan(graphToScan);
+ ///
+ /// // Recalculate only the first and third graphs
+ /// var graphsToScan = new [] { AstarPath.active.data.graphs[0], AstarPath.active.data.graphs[2] };
+ /// AstarPath.active.Scan(graphsToScan);
+ ///
+ ///
+ /// See: graph-updates (view in online documentation for working links)
+ /// See: ScanAsync
+ ///
+ /// // Recalculate all graphs
+ /// AstarPath.active.Scan();
+ ///
+ /// // Recalculate only the first grid graph
+ /// var graphToScan = AstarPath.active.data.gridGraph;
+ /// AstarPath.active.Scan(graphToScan);
+ ///
+ /// // Recalculate only the first and third graphs
+ /// var graphsToScan = new [] { AstarPath.active.data.graphs[0], AstarPath.active.data.graphs[2] };
+ /// AstarPath.active.Scan(graphsToScan);
+ ///
+ ///
+ /// See: graph-updates (view in online documentation for working links)
+ /// See: ScanAsync
+ ///
+ /// foreach (Progress progress in AstarPath.active.ScanAsync()) {
+ /// Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
+ /// }
+ ///
+ /// You can scan graphs asyncronously by yielding when you loop through the progress.
+ /// Note that this does not guarantee a good framerate, but it will allow you
+ /// to at least show a progress bar during scanning.
+ ///
+ /// IEnumerator Start () {
+ /// foreach (Progress progress in AstarPath.active.ScanAsync()) {
+ /// Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
+ /// yield return null;
+ /// }
+ /// }
+ ///
+ ///
+ /// See: Scan
+ ///