- Home /
Inaccurate A* Pathfinding Scan!
Hi, I've been trying to implement A* pathfinding but it is having trouble in accurately scanning the colliders in my scene. The background should be entirely filled with blue squares but it is not due to some issues with the tile colliders. The pathfinding component is using 2D physics and the diameter for the circles is set to 1. However, it doesn't seem to produce better results if I decrease the number to 0.99 or 0.98.
Below is the image of the platforms and its colliders. They have been set to the ground layer and are the only objects in the scene on the ground layer. I'm at my wit's end with this and would appreciate any and all help!
It looks like your system is blocking off anything within 1 cardinal square of a impassible square. As there isn't an A* built into Unity, you might need to post some relevant code for anyone to help you further.
Hi, thanks for commenting. I imported an A* Pathfinding package from https://arongranberg.com/astar/download. At this point, there is no code because the A* scan is not accurately deciphering a proper grid in the first place. I'm not sure why it sees some cells as obstacles even when the tile colliders are fairly accurate.
Well, are there other Collider types maybe? You might not want Circle, but maybe there's a Rectangle option?
The Answers site isn't super great for extended discussion or something like "hey I downloaded some code from the internet and it doesn't work", but we will try within reason.
Hi Endogeny!
Did you ever find a solution to this problem? I'm encountering the same exact thing and since it has been a while since you posted I thought that maybe you figured it out. I tried playing around with my composite collider but to no avail.
Answer by Cratuss96 · Dec 27, 2020 at 02:47 AM
its because of the composite colider. The Composite collider has a verrrrrrryyyyy small offset of (5e-07). Thats why it often messes up float numbers. If you deactivate the composite then it should work fine. btw i love that you use the same tileset "kings and pigs" as i do
Answer by MarshCZA · Mar 04, 2020 at 02:55 PM
As a sanity check have you tried a much smaller diameter, like 0.1?
Anything below a diameter of 9.8 just doesn't register any obstacles :( thanks anyways
Answer by Spaceshark123 · Jun 23, 2021 at 01:57 PM
@Endogeny I have had this problem personally with my tilemap and composite collider and the fix for it is to change the composite collider geometry type to polygons and regenerate the A Star navmesh scan.
Hope this helps! ,@Endogeny I have had this problem personally with my tilemap and composite collider and the fix for it is to change the composite collider geometry type to polygons and regenerate the A Star navmesh scan.
Hope this helps!
Your answer
Follow this Question
Related Questions
How to make enemies take wider routes? 1 Answer
astar' AI falls down, doesn't follow the grid 2 Answers
How to make AIPath (A*) work on 2D game ? 1 Answer
How to find the shortest path? 1 Answer