- A* version: 5.3.1
- Unity version: 6000.0.34f1
I’ve been using FollowerEntity and GetRemainingPath to generate a path preview of where the agent will travel in game. I recently added Off-mesh links and noticed a number of leak detected console logs. These seem to be the relevant parts of the stack trace:
0x000001502b6c0ceb (Mono JIT Code) Pathfinding.Collections.NativeCircularBuffer
1<Unity.Mathematics.float3>:Clone () (at ./Packages/com.arongranberg.astar/Core/Collections/NativeCircularBuffer.cs:324) 0x000001502b6c0a83 (Mono JIT Code) Pathfinding.Funnel/FunnelState:Clone () (at ./Packages/com.arongranberg.astar/Utilities/Funnel.cs:439) 0x000001502b6c0233 (Mono JIT Code) Pathfinding.PathTracer:Clone () (at ./Packages/com.arongranberg.astar/Utilities/PathTracer.cs:1980) 0x0000014fc83a830b (Mono JIT Code) Pathfinding.FollowerEntity:GetRemainingPath (System.Collections.Generic.List
1<UnityEngine.Vector3>,System.Collections.Generic.List1<Pathfinding.Util.PathPartWithLinkInfo>,bool&) (at ./Packages/com.arongranberg.astar/Core/AI/FollowerEntity.cs:1639) 0x0000014fc83a779b (Mono JIT Code) Pathfinding.FollowerEntity:GetRemainingPath (System.Collections.Generic.List
1<UnityEngine.Vector3>,bool&) (at ./Packages/com.arongranberg.astar/Core/AI/FollowerEntity.cs:1594)
To replicate the issue:
- Setup getting started scene for recast graph up to ’ Ignore the agent when scanning the graph’
- Add a Link2 so that the agent can travel from the ground onto one of the boxes in the scene
- Add a script to the agent which will Debug.Log the GetRemainingPath Vector3 list result
- Play the scene and traverse the link
- Stop the scene
- Play the scene again
When the scene loads a second time is when I’m getting logs about detected leaks.
The script I’m using to output the path is:
using System.Collections.Generic;
using Pathfinding;
using UnityEngine;
public class AllocationTest : MonoBehaviour
{
private FollowerEntity _followerEntity;
private float _updateTimer = 0.0f;
private List<Vector3> _path;
private bool _wasPathLogged;
void Start()
{
_followerEntity = GetComponent<FollowerEntity>();
_path = new();
_wasPathLogged = true;
}
void Update()
{
_updateTimer += Time.deltaTime;
if (_updateTimer >= 1.0f)
{
_path.Clear();
_followerEntity.GetRemainingPath(_path, out bool stale);
_updateTimer = 0.0f;
_wasPathLogged = false;
}
else if (!_followerEntity.pathPending && !_wasPathLogged)
{
foreach (var point in _path)
{
Debug.Log(point);
}
_wasPathLogged = true;
}
}
}
I’m pretty new to using Off-mesh links so I’m not sure if this is something I’m doing wrong or if I’m using GetRemainingPath in the wrong way. I’m using URP if that makes any difference.