Pathfinding Beta 4.1.4
Unity 2017.1.0p4
.Net API 3.5 (Default)
Reproduction Steps
- Open Example10_LayeredGridGraph Scene
- Change all Bots to ‘Repath Rate’ of 3 seconds
- Add ‘SearchPathOnClick’ script:
[code]using Pathfinding;
using UnityEngine;
[RequireComponent(typeof(AIPath))]
[RequireComponent(typeof(Seeker))]
public class SearchPathOnClick : MonoBehaviour {
AIPath aiPath;
Seeker seeker;
private void Awake() {
aiPath = GetComponent<AIPath>();
seeker = GetComponent<Seeker>();
}
private void Update() {
if( Input.GetKeyDown( KeyCode.Mouse0) ) {
aiPath.SearchPath();
}
if( Input.GetKeyDown(KeyCode.Mouse1) ) {
seeker.CancelCurrentPathRequest();
}
}
}
[/code]
4. Run Scene
5. Left Click to Search Path, then quickly Right Click to cancel path request (very quickly almost at the same time).
Expected Result
Path seach is canceled, no visual indication.
Actual Result
InvalidOperationException: Would overwrite error log. Do not call FailWithError multiple times.
Pathfinding.Path.FailWithError (System.String msg) (at Assets/AstarPathfindingProject/Core/Path.cs:400)
Pathfinding.Seeker.CancelCurrentPathRequest (Boolean pool) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:141)
SearchPathOnClick.Update () (at Assets/AstarPathfindingProject/ExampleScenes/ExampleScripts/SearchPathOnClick.cs:22)
errorLog just contains “Canceled by script (Seeker.CancelCurrentPathRequest)”
This happens in my game when putting an enemy back into an enemy pool, I call Seeker.CancelCurrentPathRequest before putting them back in the pool. I don’t use gameObject.SetActive(false) due to performance problems.
I just commented out the throwing of the exception, seems okay.
I also have another problem that I haven’t been able to create simple reproduction steps for yet.
IndexOutOfRangeException: Array index is out of range.
Pathfinding.PathHandler.GetPathNode (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Core/PathHandler.cs:190)
Pathfinding.PointNode.Open (Pathfinding.Path path, Pathfinding.PathNode pathNode, Pathfinding.PathHandler handler) (at Assets/AstarPathfindingProject/Generators/NodeClasses/PointNode.cs:128)
Pathfinding.ABPath.CalculateStep (Int64 targetTick) (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:555)
Pathfinding.Path.Pathfinding.IPathInternals.CalculateStep (Int64 targetTick) (at Assets/AstarPathfindingProject/Core/Path.cs:776)
Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:329)
UnityEngine.Debug:LogException(Exception)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:383)
Pathfinding.<PathProcessor>c__AnonStorey1:<>m__0() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:95)
A few other exceptions I get:
ArgumentException: Path must have a length of at least 2
Pathfinding.Util.PathInterpolator.SetPath (System.Collections.Generic.List`1 path) (at Assets/AstarPathfindingProject/Core/Misc/PathInterpolator.cs:81)
Pathfinding.AIPath.OnPathComplete (Pathfinding.Path newPath) (at Assets/AstarPathfindingProject/Core/AI/AIPath.cs:188)
Pathfinding.Seeker.OnPathComplete (Pathfinding.Path p, Boolean runModifiers, Boolean sendCallbacks) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:269)
Pathfinding.Seeker.OnPathComplete (Pathfinding.Path path) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:237)
Pathfinding.Path.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:717)
Pathfinding.Path.Pathfinding.IPathInternals.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:771)
Pathfinding.PathReturnQueue.ReturnPaths (Boolean timeSlice) (at Assets/AstarPathfindingProject/Core/Misc/PathReturnQueue.cs:55)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:770)
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
Pathfinding.Util.PathInterpolator.MoveToCircleIntersection2D (Vector3 circleCenter3D, Single radius, IMovementPlane transform) (at Assets/AstarPathfindingProject/Core/Misc/PathInterpolator.cs:170)
Pathfinding.AIPath.MovementUpdateInternal (Single deltaTime, UnityEngine.Vector3& nextPosition, UnityEngine.Quaternion& nextRotation) (at Assets/AstarPathfindingProject/Core/AI/AIPath.cs:226)
Pathfinding.AIBase.MovementUpdate (Single deltaTime, UnityEngine.Vector3& nextPosition, UnityEngine.Quaternion& nextRotation) (at Assets/AstarPathfindingProject/Core/AI/AIBase.cs:345)
Pathfinding.AIBase.FixedUpdate () (at Assets/AstarPathfindingProject/Core/AI/AIBase.cs:337)
I also can sometimes get these 3 in a row:
IndexOutOfRangeException: Array index is out of range.
Pathfinding.PathHandler.GetPathNode (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Core/PathHandler.cs:190)
Pathfinding.PointNode.Open (Pathfinding.Path path, Pathfinding.PathNode pathNode, Pathfinding.PathHandler handler) (at Assets/AstarPathfindingProject/Generators/NodeClasses/PointNode.cs:128)
Pathfinding.ABPath.Initialize () (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:423)
Pathfinding.Path.Pathfinding.IPathInternals.Initialize () (at Assets/AstarPathfindingProject/Core/Path.cs:775)
Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:319)
UnityEngine.Debug:LogException(Exception)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:383)
Pathfinding.<PathProcessor>c__AnonStorey1:<>m__0() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:95)
Followed by:
Unhandled exception during pathfinding. Terminating.
UnityEngine.Debug:LogError(Object)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:384)
Pathfinding.<PathProcessor>c__AnonStorey1:<>m__0() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:95)
And then:
Error : This part should never be reached.
UnityEngine.Debug:LogError(Object)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:390)
Pathfinding.<PathProcessor>c__AnonStorey1:<>m__0() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:95)
This could be me doing something strange though since I can’t reproduce it on the example scenes yet. I think it is related to “Couldn’t find a node close to the end point” sometimes?
I changed AIPath:OnPathComplete from:
if (p == null) throw new System.Exception("This function only handles ABPaths, do not use special path types");
to:
if (p == null || p.vectorPath == null || p.vectorPath.Count < 2 ) throw new System.Exception("This function only handles ABPaths, do not use special path types");
I’m not sure exactly how I get it into that state though, I do create & destroy multiple NavGraphs at runtime.
If I can find simpler repro steps I’ll post them.