Slow GetNearest?


#1

Hi, I am using “AstarPath.active.GetNearest(point, nn);” a lot on agents to see if a sampled position is on the graph. From what I understand is that this is the equivalent to NavMesh.SamplePosition. However in my project the astar way is very slow. Right now it is what takes most of my frame time. The old NavMesh way was not even close as slow.

I should point out that I´m doing quite a lot of GetNearest checks. Maybe 30 per agent every second or so with 20-30 agents in the scene. Since this worked without problems with the NavMesh.SamplePosition i figured it should work with Astar also.

Am I doing something wrong here or is this the expected performance, maybe there is a way to check if a point is walkable cheaper than this?

Any help is appreciated

Edit: Im using a Navmesh, exported from Recast


#2

Hi

Are you using the pro version or the free version? And which version number of the package are you using?


#3

I am using the Pro version, 3.8.6.


#4

Any help on this issue?


#5

Hi

Sorry.
The checks should be quite fast, though I think with that version (and earlier versions) the AABB-tree that is constructed is sometimes deeper than necessary which can slow down lookups significantly in some cases.
You could try out a preview version where I have done some optimizations for the AABB-tree.


#6

Sure, what version should I test?


#7

I have sent you a PM with a download link. Note that gizmo drawing in that version may not work properly on Windows if you are using Unity 5.4 or greater. Make sure to create a backup of your project first as this update does have some breaking changes.


#8

Any luck with the preview version?