A* Project NavmeshCut + Agents Navigation plugin - InvalidOperationException: Couldn't find a portal

  • A* version: 5.3.1
  • Agents Navigation version: 4.0.12
  • Unity version: 6000.0.31f

Hello @aron_granberg, I found a problem when using A* star project in conjunction with Agents Navigation package . Although it seems like it’s not crashing anything it is reporting multiple errors, which is kinda annoying. The problem is related to the Recast graph and NavmeshCut component.

I was able to reproduce the problem in empty project and I recorded the video which you can find HERE: https://www.youtube.com/watch?v=e9zNIgQjvQo

To reproduce it too please follow these steps:

  1. Import A* Pathfinding Project Pro and create Recast graph on selected surface
  2. Import Agents Navigation, create agent with these components: Agent, Agent Cylinder Shape, Agent Astar Pathing - probably not even all of these are needed in order to reproduce the bug… in the video the agent is BLUE CYLINDER
  3. Create target (GOLDEN SMALL CUBE in the video) for the agent, make simple script for the agent to follow the target (in update I have this: IF golden cube destination changed, THEN _agent.SetDestination(goldenCubeTransform );
  4. Create another cube with NavmeshCut component from A* package. This cube will do navmesh cutting, on the video it is represented by RED BIG CUBE
  5. Start the scene, you can see agent moving towards the target. Now move the navmesh cutter object, so the navmesh and path towards the destination are recomputed
  6. Sooner or later errors appear (see video for more info): InvalidOperationException: Couldn’t find a portal from Pathfinding.TriangleMeshNode Pathfinding.TriangleMeshNode

I was trying to reproduce this behaviour on your A* proj Recast3D sample with no luck (no error appearing no matter how crazily I moved with navmesh cutter), so I presume that the problem is tightly connected with Agents Navigation package usage.

Could you please take a look on this, eventually also collaborate with Lucas (Agents navigation creator) to solve this issue? Lucas has been already notified about this issue.

Thank you in advance for your time and effort!

This does look like it may be more on the side of Agents Navigation since the asset has an extension for Astar and it only happens when Agents Navigation is added. Also it says 5.0.8 but that may just be outdated. Has Lucas gotten back to you yet?

Is there a stack trace to that exception? If so, can you add it here?

Yes, I also believe the problem is more on the Agents Navigation side, I will ping Lucas again. Stack trace follows:

InvalidOperationException: Couldn`t find a portal from Pathfinding.TriangleMeshNode Pathfinding.TriangleMeshNode False
Pathfinding.PathTracer.CalculateFunnelPortals (System.Int32 startNodeIndex, System.Int32 endNodeIndex, System.Collections.Generic.List`1[T] outLeftPortals, System.Collections.Generic.List`1[T] outRightPortals) (at ./Packages/com.arongranberg.astar/Utilities/PathTracer.cs:1659)
Pathfinding.PathTracer.SetFunnelState (Pathfinding.Funnel+PathPart part) (at ./Packages/com.arongranberg.astar/Utilities/PathTracer.cs:1635)
Pathfinding.PathTracer.SetPath (System.Collections.Generic.List`1[T] parts, System.Collections.Generic.List`1[T] nodes, UnityEngine.Vector3 unclampedStartPoint, UnityEngine.Vector3 unclampedEndPoint, Pathfinding.Util.NativeMovementPlane movementPlane, Pathfinding.PathRequestSettings pathfindingSettings, Pathfinding.Path path) (at ./Packages/com.arongranberg.astar/Utilities/PathTracer.cs:1969)
Pathfinding.PathTracer.SetPath (Pathfinding.ABPath path, Pathfinding.Util.NativeMovementPlane movementPlane) (at ./Packages/com.arongranberg.astar/Utilities/PathTracer.cs:1934)
Pathfinding.ECS.ManagedState.SetPath (Pathfinding.Path path, Pathfinding.ECS.ManagedState state, Pathfinding.ECS.AgentMovementPlane& movementPlane, Pathfinding.ECS.DestinationPoint& destination) (at ./Packages/com.arongranberg.astar/Core/ECS/Components/ManagedState.cs:122)
UnityEngine.Debug:LogException(Exception)
Pathfinding.ECS.ManagedState:SetPath(Path, ManagedState, AgentMovementPlane&, DestinationPoint&) (at ./Packages/com.arongranberg.astar/Core/ECS/Components/ManagedState.cs:132)
Pathfinding.ECS.JobRepairPath:Execute(LocalTransform&, MovementState&, AgentCylinderShape&, AgentMovementPlane&, AutoRepathPolicy&, DestinationPoint&, EnabledRefRW`1, ManagedState, MovementSettings&, NativeList`1, NativeArray`1&, Allocator, Boolean) (at ./Packages/com.arongranberg.astar/Core/ECS/Jobs/JobRepairPath.cs:158)
ProjectDawn.Navigation.Astar.AstarPathJob:Execute(ArchetypeChunk&, Int32, Boolean, v128&) (at ./Packages/com.projectdawn.navigation/ProjectDawn.Navigation.Astar/AstarPathingSystem.cs:346)
ProjectDawn.Navigation.Astar.AstarPathJob:Unity.Entities.IJobChunk.Execute(ArchetypeChunk&, Int32, Boolean, v128&)
Unity.Entities.JobChunkProducer`1:ExecuteInternal(JobChunkWrapper`1&, IntPtr, JobRanges&, Int32) (at ./Library/PackageCache/com.unity.entities/Unity.Entities/IJobChunk.cs:451)
Unity.Entities.JobChunkProducer`1:Execute(JobChunkWrapper`1&, IntPtr, IntPtr, JobRanges&, Int32) (at ./Library/PackageCache/com.unity.entities/Unity.Entities/IJobChunk.cs:363)

Yeah if he gets back to you, let us know! In the meantime, what version is your Entities package at? Anytime I see Entities involved I always raise an eyebrow because it seems to cause a lot of issues haha. Check that and see if it may need an update?

I am currently using Entities 1.3.8 - I can try update to 1.3.9 but I don’t actually expect that this will solve the problem… will let you know when I will know more about this problem. Thank’s for trying to help, appreciate it!

1 Like