Intense slowdown when pathfinding objects overlap

Not sure if this is a bug, but I noticed this issue when a bunch of my seekers with basic polygon colliders happened to overlap. I then created a fresh project to test this issue by running this test:

three identical game objects with the following components:

  • Rigidbody2D (dynamic)
  • Seeker + AI destination setter (set to 2D)
  • Very complex polygon collider (~200 sides) set to trigger

Whenever these two game objects overlapped they would cause intense slowdown to the point of crashing unity, and when they overlapped an object without a seeker they would still cause mild slowdown. What I concluded is that the complexity of a polygon collider has a massive effect on the pathfinding components performance.

I thought I’d point this out because it might be a bug leading to performance issues (or I’m just not supposed to have rigidbody2D and A* active on the same object)

Using unity 2021.3.1f1
Using A
Pro 4.2.18*

Hi

Do you have a screenshot of the Unity profiler, to see what is causing the slowdown?

Sure thing, here’s my profiler (performance spike is when characters overlap):

here’s how the profiler looks when rigidbody components are removed:

Since it is orange, that indicates it is a physics based slowdown. Likely the physics engine has a tough time with all the overlap. This does not come from the pathfinding scripts themselves, though.

Ahh I just realized I was testing against unmoving dynamic objects…oof I feel stupid now. Sorry to waste your time!

1 Like