Seeker passing through 2D obstacles marked as collidable

Based on the simple 2D pathfinding project, I’m again trying a setup with my own scene. One seeker, 2D grid (50x50, offset by 0.5 so the non-traversable nodes ARE detected correctly.) What I’m seeing is that the seeker is sometimes passing straight through what should be solid, non-traversable areas.

Left: Before, Right: Paused during movement

I’ve tried both Circle and Point collision for the path. Using standard 1 unit width x height box colliders spaced exactly 1 unit apart. Looking at it in scene mode with the sprites off, the non-traversable tiles do appear to be in the right place, exactly aligning with the sprites.

Am I missing something here…?

This is the movement code I’m using (boilerplate stuff) -
https://pastebin.com/eu6nPwB9

GIF:

Hi

The AIPath script always move towards the intersection of the green path with that blue circle (which shows the ‘pick next waypoint distance’). If you want the AI to follow the path more closely you can use a smaller ‘pick next waypoint distance’.

The get started video tutorial also touches on this subject if you want more info.

Additionally you may want to disable the ‘cut corners’ option in the grid settings.

If you want the AI to follow the green path exactly, never deviating the slightest, then you should use the AILerp movement script.

I tried setting the “Next Waypoint Distance” to 0.1 and disabling Cut Corners, but the seeker is still moving directly through non-traversable objects. It’s not that I want the seeker to follow the green path 100% exactly, but they shouldn’t be moving through obstacles at all, right? How can I avoid that behavior?

I think one of the problems here is I’m not understanding how to set the ‘size’ of the seeker / AI? I don’t see anything in the docs about this, or any settings in AIPath / Seeker components. What if I wanted it to be, say, 3 units high?

Hi

That does not look like you have reduced the next waypoint distance. Do you think you could enable ‘Always Draw Gizmos’ on the AIPath component again?

The size of the agent is baked into the graph for pathfinding purposes. It is controlled primarily through the ‘diameter’ setting in the Grid Graph’s collision settings.

I have tried reducing it. In the below GIF it’s set to 0.001 in the editor. Still passing directly through solid obstacles…

To be clear, it’s not possible to have seekers of varying size? For example, most RTS games have units of different sizes - small ones can pass through spaces that large ones cannot.

Hi

Are you sure you are modifying the right component? That blue circle should have a radius equal to the value of ‘pick next waypoint distance’.

Also. Take a look at this tutorial: https://arongranberg.com/astar/docs/multipleagenttypes.html
Though the beta version of that tutorial describes a few more techniques: https://arongranberg.com/astar/documentation/dev_4_1_14_3886c2bf/multipleagenttypes.html

Yes, I’m positive. There is only one seeker in the scene. The “next waypoint distance” field is used exactly as it is in the tutorial code.

FWIW I switched to AILerp and that seems to be working perfectly. Maybe this is just a bug with AIPath…?

Well, the Seeker component isn’t the one which has the next waypoint distance field. Do you think you could send me a screenshot of your unity window with the agent selected?

Here is a video I just made with a good value (0.7 in this case): http://arongranberg.com/temp/video_07_default.mp4
and here is another one with a too large value (2.0 in this case): http://arongranberg.com/temp/video_20_default.mp4

Yeah if you want the agent to follow the path without any deviations at all, then AILerp is better.

Sorry, to clarify, I was using “Seeker” to describe an object that is building the path. I used a simple custom “Monster” component utilizing the exact tutorial code (including the Next Waypoint Distance) along with the Seeker/AIPath components attached. I’m happy to send the scene I was using if you want to experiment with it as this does seem like a bug?

Oh wait, have you been following this tutorial: https://arongranberg.com/astar/docs/custom_movement_script.html?
That tutorial is for creating a movement script that works similarly to the AIPath script, if you have both that script and your script attached both will try to move the character at the same time. Try to keep only one of them attached.