2D Pathfinding player always running into collider

Hi Aron and community,

First of all, amazing project, this looks very promising.
I’m just getting started with this package, but after 3 hours of trying to set up 2D pathfinding with collisions, I’m getting stuck because my player game object always runs into walls/unwalkable areas, without following the target spline properly. The player then stops instead of following the calculated path.

I made a GIF in order to display my issue:
https://drive.google.com/file/d/14GN556AoUtS7Q4Y88UgG1LtdUqI9y-_m/view?usp=sharing

For my background, I’m using a standard tilemap in Unity, with a “Composite Collider 2D” taking care of collisions, in combination with a “Rigidbody2D” component on the collider grid. This collider is part of the “Collision” layer, which I then set as the “Obstacle Layer Mask” on the “Pathfinder” script.

Here are my settings:


As for the player movement itself, I’m calculating the mouse click’s world space position, then feeding that Vector3 to the class property GetComponent().destination

That’s about it. Please let me know if you need any additional info to debug this, any help would be appreciated. I have a feeling this must be something rather easy to solve, since it’s so basic.

Thanks a lot,
Manu

Hi

Try reducing the ‘pick next waypoint distance’ field on the AIPath component. That will make it follow the path more closely.

Hi Aron,

Thank you very much, that totally solved the issue! Your pathfinding asset is amazing!

Best,
Manu

1 Like